Jump to: navigation, search

Difference between revisions of "FAQ How do I inform the user of a problem?"

 
(Platform UI Error Handling has a consistent approach to working with errors)
 
Line 25: Line 25:
 
== See Also: ==
 
== See Also: ==
  
 +
[[Platform UI Error Handling]]
  
 
[[FAQ_How_do_I_use_the_platform_logging_facility%3F]]
 
[[FAQ_How_do_I_use_the_platform_logging_facility%3F]]
 
  
 
[[FAQ_How_do_I_create_a_dialog_with_a_details_area%3F]]
 
[[FAQ_How_do_I_create_a_dialog_with_a_details_area%3F]]
  
 
<hr><font size=-2>This FAQ was originally published in [http://www.eclipsefaq.org Official Eclipse 3.0 FAQs]. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the [http://www.eclipse.org/legal/epl-v10.html Eclipse Public License v1.0].</font>
 
<hr><font size=-2>This FAQ was originally published in [http://www.eclipsefaq.org Official Eclipse 3.0 FAQs]. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the [http://www.eclipse.org/legal/epl-v10.html Eclipse Public License v1.0].</font>

Latest revision as of 10:46, 28 August 2009

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);
   ErrorDialog.openError(window.getShell(), 
      "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

FAQ_How_do_I_use_the_platform_logging_facility?

FAQ_How_do_I_create_a_dialog_with_a_details_area?


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.