Creating and registering an error source
Prev | Chapter 6. The error reporting API | Next

## Creating and registering an error source

Errors are managed by implementations of the `errorlist.ErrorSource` abstract class. Extending this class is a bit involved and requires writing a lot of low-level code; most plugins can use the `errorlist.DefaultErrorSource` class instead, which provides a very easy-to-use front-end.

The constructor for the `DefaultErrorSource` class accepts one parameter; a string that will identify the error source. Currently, this identifier is not used, but in the future the ErrorList plugin might show which error comes from which plugin, for example.

Error sources should be registered when the user first invokes your plugins. A plugin can create any number of error sources. The Console plugin, for example, maintains a separate error source for each console window, and registers an unregisters them as consoles are opened and closed.

To add an error source to the list of registered error sources, you must call the static `registerErrorSource()` method of the `errorlist.ErrorSource` class.

A corresponding `unregisterErrorSource()` method must be called before your plugin is unloaded to avoid leaking memory.

Prev | Up | Next
Specifying dependencies | Home | Reporting errors