sk.baka.ambient
Class ErrorHandler

java.lang.Object
  extended by sk.baka.ambient.ErrorHandler

public final class ErrorHandler
extends Object

Handles errors that occurs in the application. Thread-safe.

Author:
Martin Vysny

Nested Class Summary
static class ErrorHandler.ErrorInfo
          Contains information about an error.
 
Constructor Summary
ErrorHandler(AmbientApplication app)
          Creates new handler instance.
 
Method Summary
 void clear()
          Clears all recorded error messages.
 void error(Class<?> sender, boolean error, String message, Throwable cause)
          An error occurred.
 List<ErrorHandler.ErrorInfo> getErrors()
          Returns a new copy of the recorded error list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ErrorHandler

ErrorHandler(AmbientApplication app)
Creates new handler instance.

Parameters:
app - owner application.
Method Detail

error

public void error(Class<?> sender,
                  boolean error,
                  String message,
                  Throwable cause)
An error occurred. A notification will be shown to the user.

Parameters:
sender - the sender.
error - error if true, warning if false.
message - the message to show. The message will be followed by a new line, the Cause: string and the Throwable.getMessage() if the cause is not null.
cause - optional cause.

getErrors

public List<ErrorHandler.ErrorInfo> getErrors()
Returns a new copy of the recorded error list.

Returns:
non-null list of errors.

clear

public void clear()
Clears all recorded error messages. Must be invoked from the Handler thread.



Copyright © 2007-2008. All Rights Reserved.