Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "E4/EAS/Status Handling"

< E4‎ | EAS
(Eclipse 3.x API)
(e4 (Java))
Line 31: Line 31:
 
<source lang="java">
 
<source lang="java">
 
@Inject Provider<StatusHandler> statusHandler;
 
@Inject Provider<StatusHandler> statusHandler;
 +
@Inject Provider<StatusReportingService> statusReportingService;
 
   
 
   
 
public void foo() {
 
public void foo() {
Line 36: Line 37:
 
     // some operation
 
     // some operation
 
   } catch (SomeException ex) {
 
   } catch (SomeException ex) {
     statusHandler.get().handle(ex, "some message", StatusHandler.SHOW);
+
     statusHandler.get().handle(ex, IStatus.ERROR, "some message", statusReportingService.get());
 
   }
 
   }
 
}
 
}
 
</source>
 
</source>
 +
 +
* The calling code believes that SomeException is an error
 +
* The StatusHandler may decide to reinterpret severity depending on how it is configured.  Additional information could be collected, etc.
 +
* The StatusReportingService decides how the error is shown (in a wizard, in an error dialog, in the log, transmit to a help desk, open a bug)

Revision as of 15:19, 29 October 2009

(Status: in progress)

Something unexpected happened in a component, for example:

  • an operation requested by the user could not be performed at all
  • an operation could only be performed partially
  • an exception happened, but there is no immediate consequence for the user

Typically, in these situation, some or all of the following are known:

  • how severe the situation is
  • if the user needs to be informed
  • if the user can do anything about it
  • a string describing the unexpected situation
  • an exception
  • an application-specific object that should be made available to application-level error handling code

Eclipse 3.x API

StatusManager.getManager().handle(status, style) where style is a hint (one of BLOCK, SHOW, LOG), the status object contains the descriptive string, the severity (INFO, WARNING, ERROR), and an optional exception

Critique:

  • The API does not separate the client API (notifying about a problem) from the service provider API (acting on a problem).
    • The calling code has to know how the info is presented (BLOCK, SHOW, LOG)
    • There is no way to hook in and override or augment the error info between the time the client reports it and the time the service provider shows it
  • The API is currently defined in a UI bundle and as such is not available to lower level bundles.
  • We use the Singleton Pattern and thus each client must provide information about itself (like e.g. the plugin id) that could be computed automatically.
  • There is no relationship between global error reporting schemes (log, error dialog) and 3.x local error reporting schemes (status dialogs, wizard pages, etc.) It should be possible to report an asynchronous error in a wizard if the wizard is the one that started the operation
  • Some asynchronous errors are expected by the calling code and there is no way to specify at that time what actions are suggested or could be taken by the user.

e4 (Java)

Clients should be able to write something like:

@Inject Provider<StatusHandler> statusHandler;
@Inject Provider<StatusReportingService> statusReportingService;
 
public void foo() {
  try {
    // some operation
  } catch (SomeException ex) {
    statusHandler.get().handle(ex, IStatus.ERROR, "some message", statusReportingService.get());
  }
}
  • The calling code believes that SomeException is an error
  • The StatusHandler may decide to reinterpret severity depending on how it is configured. Additional information could be collected, etc.
  • The StatusReportingService decides how the error is shown (in a wizard, in an error dialog, in the log, transmit to a help desk, open a bug)

Back to the top