Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: for the plan.

Jump to: navigation, search

FAQ How do I inform the user of a problem?

Revision as of 11:46, 28 August 2009 by (Talk | contribs) (Platform UI Error Handling has a consistent approach to working with errors)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Warnings and errors can be reported to the user by using an ErrorDialog. Here is a very simple example of an Error dialog displaying a warning message:

   IStatus warning = new Status(IStatus.WARNING, 
      ExamplesPlugin.ID, 1, "You have been warned.", null);
      "This is your final warning", null, warning);

The null parameter to the status constructor is for supplying an exception object. The exception object is not used by the Error dialog, so we’ll leave it blank in this case. If you’re creating a status object for another purpose, such as logging, you’ll want to supply the exception, if there is one. The openError method has parameters for a title and a message, but both of these parameters are optional. If you don’t supply a title, the method will use the generic Problems Occurred message. If you don’t supply a message, the method will take the message from the supplied status object.

See Also:

Platform UI Error Handling



This FAQ was originally published in Official Eclipse 3.0 FAQs. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the Eclipse Public License v1.0.

Back to the top