com.sdm.quasar.client.core.common
Interface ErrorContextHandler


public interface ErrorContextHandler

Interface for error handlers, that can handle specific exceptions in specific contexts. ExceptionHandlers are added to the ErrorHandler singleton. The order is important, because the last added ErrorContextHandler is threaded as the most specific; e.g. it will be asked first to handle exceptions. If an ErrorContextHandler throws an exception (means, it cannot handle the exception), this exception will tried to get handled by the ErrorContextHandler added before and so on.

Version:
1.0
Author:
Thomas Wolf

Method Summary
 boolean canHandle(java.lang.Object context, java.lang.Throwable e)
          Returns true, if this ErrorContextHandler can handle the given context and Throwable.
 void handleError(java.lang.Object context, java.lang.Throwable e)
          Handles the exception given.
 

Method Detail

canHandle

public boolean canHandle(java.lang.Object context,
                         java.lang.Throwable e)
Returns true, if this ErrorContextHandler can handle the given context and Throwable.

Parameters:
context - the context given by the caller (may be null)
e - the Throwable to handle (not null)
Returns:
true iff can handle exception using handleError(Object, Throwable)

handleError

public void handleError(java.lang.Object context,
                        java.lang.Throwable e)
                 throws java.lang.Throwable
Handles the exception given. It is guaranteed by the caller (ErrorHandler), that this method is only called when canHandle(Object, Throwable) with the same arguments has returned true.

Parameters:
context - the context given by the caller (may be null)
e - the Throwable to handle (not null)
Throws:
java.lang.Throwable - an exception that can be handled by a previously added ErrorContextHandler (see ErrorHandler).