[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.tools] Re: Handling exceptions in UI plug-ins

Depends on the context. People can put up a dialog if that makes sense in
their context.  In the platform we often catch and log (e.g., when running
builders) if the failure is not criticial to the continued health of the
platform.

It is important that people catch exceptions when they call random code from
other (untrusted) plugins.  See ISafeRunnable for some built-in support for
this.  This standars support will likely be improved over time as the kinds
of problems that come up are better understood.  Blindly catching Throwable,
Error and even Exception can be dangerous (e.g. you would not want to catch
and ignore OutOfMemoryError).

As for logging, Log is internal but ILog is public.  Each plugin has its own
ILog object (see Plugin.getLog()).  ILogs do not map onto files on disk or
windows on the screen.  They are logical (no pun intended) event
distribution points.   People do not need to implement ILog, they implement
ILogListener and register their listeners with the relevant ILogs.  Events
(status objects) logged on the ILog are then distributed to the relevant
listeners.  You can register a listener with a specific (group of) plugin or
with the platform itself (the runtime plugin).  Your listener will get only
events for which it is registered.  The runtime plugin's log gets all
events.

The platform has a default listener which grabs all events and writes them
to a file (<platform>/.metadata/.log).  There is also a command line option
(-consolelog) which installs a listener that writes the events to
System.out.  I believe that the upcoming PDE tools will have a log console
window.

Jeff

<jamsden@xxxxxxxxxx> wrote in message news:9akkfd$glm$1@xxxxxxxxxxxxxxxx
> What are the guidelines for handling exceptions in UI plug-ins? Should
> they
> post an ErrorDialog and write to the Log? I see Log, the signle
> implementation
> of ILog is internal. How does one get the Log? Is there any other
> framework support for logging errors?