SWT can trigger three types of exceptions: IllegalArgumentException, SWTException, and SWTError. Applications should not have to catch any other kind of exception or error when calling SWT.
Note: If any other exception besides these three is thrown from SWT, it should be considered a bug in the SWT implementation.
Where possible, exceptions are triggered consistently across platforms. However, some errors are specific to an SWT implementation on a particular platform.
The arguments passed in SWT API methods are checked for appropriate state and range before any other work is done. An IllegalArgumentException will be thrown when it is determined that an argument is invalid.
Code that causes an IllegalArgumentException on one platform will cause the same exception on a different platform.
SWTException is thrown when a recoverable error occurs internally in SWT. The error code and message text provide a further description of the problem.
SWT remains in a known stable state after throwing the exception. For example, this exception is thrown when an SWT call is made from a non-UI thread.
SWTError is thrown when an unrecoverable error occurs inside SWT.
SWT will throw this error when an underlying platform call fails, leaving SWT in an unknown state, or when SWT is known to have an unrecoverable error, such as running out of platform graphics resources.
Once an SWT error has occurred, there is little that an application can do to correct the problem. These errors should not be encountered during normal course of operation in an application, but high reliability applications should still catch and report the errors.