E4/EAS/Status Handling

From Eclipsepedia

< E4‎ | EAS
Revision as of 16:46, 10 November 2009 by Boris Bokowski.ca.ibm.com (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

(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

Contents

Eclipse 3.x API

public void foo() {
  try {
    // some operation
  } catch (SomeException ex) {
    // I expected this one.  Tell the user what to do, don't log.
    Status failStatus = new Status(IStatus.ERROR, "myPluginId", "Error Message", ex);
    StatusManager.getManager().handle(failStatus, StatusManager.SHOW);
  } catch (AnotherException ex) {
     // I know nothing about the details, probably an error?  Better show and log just in case
    Status failStatus = new Status(IStatus.ERROR, "myPluginId", ex.getLocalizedMessage(), ex);
    StatusManager.getManager().handle(failStatus, StatusManager.SHOW | StatusManager.LOG);
  }
}


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 local error reporting schemes (status dialogs, wizard pages, etc.). If the user opens a wizard that triggers some background work, they expect the status to be reported in the wizard rather than be interrupted by a dialog.
  • Some asynchronous errors are expected by the calling code and there is no easy way to specify what actions are suggested or could be taken by the user when the error is reported (Bug 273137).

e4 (Java)

Clients should be able to write something like:

@Inject Provider<StatusHandler> statusHandler;
 
public void foo() {
  try {
    // some operation
  } catch (SomeException ex) {
     // I thought this might happen, I think it's an error
     // The last parameter is an optional properties map if I want to seed info for known status handlers.
     // This way I can evolve my suggestions/error annotations without any API changes
     statusHandler.get().error(ex, "Error Message", null); 
     // or maybe there was no exception but we would like to report a problem
     //statusHandler.get().warning("Warning Message", null); 
  } catch (AnotherException ex) {
     // I know nothing about the details, probably an error?
     statusHandler.get().handle(ex);
  }
}

The calling code should be dead simple. The only thing the client should have to specify is what they know (if anything) about the error.

  • Client code expects some exceptions and has predefined user messages to describe what went wrong
  • Other exceptions must be caught but are not fully understood by the client. Let some default reporting happen
  • Unexpected (runtime) exceptions percolate to a global handler as today
  • Client can feed properties to the status handler to take advantage of evolving reporting schemes without breaking API

StatusHandler

  • StatusHandler consults with registered interpreter(s)
    • Chains
      • ordered lists of status interpreters
      • tree of status interpreters, where the status is passed first to plug-in interpreter(s), then to parent plug-in interpreter(s), and then to product interpreter(s).
    • Overrides
      • Service rankings determine a single winner (downside - howto annotate an error without loosing other interpretations?)
      • How to handle a tie?
        • Use a configuration file / Java system property? (can this be used to restrict chains?)
  • Status may surface as originally reported or get augmented or reinterpreted depending on configuration.
    • Gather additional information about an error when it occurs (for reporting purposes)
    • One product's error is another product's "so what?" (See Bug 174515).
    • Alternate interpretation of an error
      • Eclipse SDK: "Error: Connection timed out on http://example.com"
      • My RCP Product: "Info: The XYZ company server is down for maintenance between 6pm and 8pm. Please try again later."

StatusReportingService

See Status Reporting Service