Cumulus4j API
(1.2.0-SNAPSHOT)

org.cumulus4j.keymanager.back.shared
Class ErrorResponse

java.lang.Object
  extended by org.cumulus4j.keymanager.back.shared.Message
      extended by org.cumulus4j.keymanager.back.shared.Response
          extended by org.cumulus4j.keymanager.back.shared.ErrorResponse
All Implemented Interfaces:
Serializable

public class ErrorResponse
extends Response

Response implementation for sending an error back to the app-server. It can optionally wrap a Throwable to provide more precise information (the type) than just a message.

Author:
Marco หงุ่ยตระกูล-Schulze - marco at nightlabs dot de
See Also:
Serialized Form

Constructor Summary
ErrorResponse()
          Create an empty instance of ErrorResponse.
ErrorResponse(Request request, String errorMessage)
          Create an instance of ErrorResponse in order to reply the given request.
ErrorResponse(Request request, Throwable throwable)
          Create an instance of ErrorResponse in order to reply the given request.
 
Method Summary
 String getMessage()
          Get the error-message.
 String getType()
          Get the error-type.
 void setMessage(String errorMessage)
          Set the error-message, i.e.
 void setType(String type)
          Set the error-type.
 
Methods inherited from class org.cumulus4j.keymanager.back.shared.Response
toString
 
Methods inherited from class org.cumulus4j.keymanager.back.shared.Message
equals, getRequestID, hashCode, setRequestID
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ErrorResponse

public ErrorResponse()
Create an empty instance of ErrorResponse. Only used for serialisation/deserialisation.


ErrorResponse

public ErrorResponse(Request request,
                     String errorMessage)
Create an instance of ErrorResponse in order to reply the given request.

Parameters:
request - the request to be replied.
errorMessage - a description of what went wrong.

ErrorResponse

public ErrorResponse(Request request,
                     Throwable throwable)
Create an instance of ErrorResponse in order to reply the given request.

Parameters:
request - the request to be replied.
throwable - the error to be wrapped and sent back to the app-server instead of a normal response.
Method Detail

getType

public String getType()
Get the error-type. This is a fully qualified class-name of the Throwable-sub-class passed to ErrorResponse(Request, Throwable) or otherwise set.

Returns:
the error-type or null.
See Also:
setType(String)

setType

public void setType(String type)
Set the error-type.

Parameters:
type - the error-type or null. If not null, this must be a fully qualified class-name of the Throwable-sub-class.
See Also:
getType()

getMessage

public String getMessage()
Get the error-message. If an exception was wrapped by this ErrorResponse instance, it will be the result of Throwable.getMessage().

Returns:
the error-message.
See Also:
setMessage(String)

setMessage

public void setMessage(String errorMessage)
Set the error-message, i.e. a description of what went wrong and prevented successful handling of the request.

Parameters:
errorMessage - the error message.
See Also:
getMessage()

Cumulus4j API
(1.2.0-SNAPSHOT)

Copyright © 2013 NightLabs Consulting GmbH. All Rights Reserved.