Package dev.hilla.exception
Class EndpointException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- dev.hilla.exception.EndpointException
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
EndpointValidationException
public class EndpointException extends RuntimeException
An exception that is intended to be thrown by any Vaadin endpoint method to propagate exception details to the client side. When an exception is thrown by an endpoint method, a particular response is constructed based on the data of the exception and sent to the client side. When a client library receives the response, it raises the corresponding exception using the response data. By default, if any Vaadin endpoint method throws an exception when being invoked by the client request, the exception details are concealed due to security reasons. When there's a need to pass some information about the failure on the client side, this exception or any of its subclasses can be used. Refer to thegetSerializationData()method to see the information on the data being sent to the client. Refer toVaadinConnectExceptionin the client library for more information about the client side of the implementation.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringERROR_MESSAGE_FIELDA message field to be used in the exception's serialization data ingetSerializationData().
-
Constructor Summary
Constructors Constructor Description EndpointException(String message)Creates an exception which information is propagated to the client since, if thrown from a Vaadin endpoint method.EndpointException(String message, Object detail)Creates an exception which information is propagated to the client since, if thrown from a Vaadin endpoint method.EndpointException(String message, Throwable cause)Creates an exception which information is propagated to the client since, if thrown from a Vaadin endpoint method.EndpointException(String message, Throwable cause, Object detail)Creates an exception which information is propagated to the client since, if thrown from a Vaadin endpoint method.EndpointException(Throwable cause)Creates an exception which information is propagated to the client since, if thrown from a Vaadin endpoint method.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ObjectgetDetail()Gets the detail of the exception, if provided by user,nullotherwise.Map<String,Object>getSerializationData()Creates a map with the serialization data to be sent to the client when the exception thrown is processed byEndpointController.-
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
-
-
-
Field Detail
-
ERROR_MESSAGE_FIELD
public static final String ERROR_MESSAGE_FIELD
A message field to be used in the exception's serialization data ingetSerializationData().- See Also:
- Constant Field Values
-
-
Constructor Detail
-
EndpointException
public EndpointException(String message)
Creates an exception which information is propagated to the client since, if thrown from a Vaadin endpoint method.- Parameters:
message- the message to put in the client side exception message when an exception is thrown
-
EndpointException
public EndpointException(Throwable cause)
Creates an exception which information is propagated to the client since, if thrown from a Vaadin endpoint method. Will reuse the original exception's message when thrown.- Parameters:
cause- the original exception that had caused the current one to be thrown
-
EndpointException
public EndpointException(String message, Object detail)
Creates an exception which information is propagated to the client since, if thrown from a Vaadin endpoint method.- Parameters:
message- the message to put in the client side exception message when an * exception is throwndetail- a detail object that will be serialized into JSON and sent to the client, when the exception is thrown
-
EndpointException
public EndpointException(String message, Throwable cause)
Creates an exception which information is propagated to the client since, if thrown from a Vaadin endpoint method.- Parameters:
message- the message to put in the client side exception message when an * * exception is throwncause- the original exception that had caused the current one to be thrown.
-
EndpointException
public EndpointException(String message, Throwable cause, Object detail)
Creates an exception which information is propagated to the client since, if thrown from a Vaadin endpoint method.- Parameters:
message- the message to put in the client side exception message when an * * exception is throwncause- the original exception that had caused the current one to be throwndetail- a detail object that will be serialized into JSON and sent to the client, when the exception is thrown
-
-
Method Detail
-
getDetail
public Object getDetail()
Gets the detail of the exception, if provided by user,nullotherwise.- Returns:
- the detail of the exception
-
getSerializationData
public Map<String,Object> getSerializationData()
Creates a map with the serialization data to be sent to the client when the exception thrown is processed byEndpointController. The following data will be sent to the client:- exception type: either the original exception type or
EndpointException, if no original exception is given - message: non-blank message either from the constructor or from the original exception. If both are blank, none provided.
- detail: detail object serialized to json, if provided in the corresponding constructor
- Returns:
- the data to be sent to the client
- exception type: either the original exception type or
-
-