com.vaadin.flow.server.connect.exception.
Class EndpointException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- com.vaadin.flow.server.connect.exception.EndpointException
-
All Implemented Interfaces:
Direct Known Subclasses:
public class EndpointException extends RuntimeException
An exception that is intended to be thrown by any Vaadin Connect 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 Connect 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 the
getSerializationData()
method to see the information on the data being sent to the client. Refer toVaadinConnectException
in the client library for more information about the client side of the implementation.See Also:
-
-
Field Summary
Fields Modifier and Type Field and Description static String
ERROR_MESSAGE_FIELD
A message field to be used in the exception's serialization data in
getSerializationData()
.
-
Constructor Summary
Constructors Constructor and Description EndpointException(String message)
Creates an exception which information is propagated to the client since, if thrown from a Vaadin Connect method.
EndpointException(String message, Object detail)
Creates an exception which information is propagated to the client since, if thrown from a Vaadin Connect method.
EndpointException(String message, Throwable cause)
Creates an exception which information is propagated to the client since, if thrown from a Vaadin Connect method.
EndpointException(String message, Throwable cause, Object detail)
Creates an exception which information is propagated to the client since, if thrown from a Vaadin Connect method.
EndpointException(Throwable cause)
Creates an exception which information is propagated to the client since, if thrown from a Vaadin Connect method.
-
Method Summary
All Methods Modifier and Type Method and Description Object
getDetail()
Gets the detail of the exception, if provided by user,
null
otherwise.Map<String,Object>
getSerializationData()
Creates a map with the serialization data to be sent to the client when the exception thrown is processed by
VaadinConnectController
.-
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 in
getSerializationData()
.See Also:
-
-
Constructor Detail
-
EndpointException
public EndpointException(String message)
Creates an exception which information is propagated to the client since, if thrown from a Vaadin Connect 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 Connect 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 Connect 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 Connect 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 Connect 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,
null
otherwise.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 by
VaadinConnectController
. 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
-
-