com.vaadin.hilla.exception.

Class 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 the getSerializationData() method to see the information on the data being sent to the client. Refer to VaadinConnectException in the client library for more information about the client side of the implementation.

See Also:

  • Field Details

  • Constructor Details

    • 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 thrown

      detail - 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 thrown

      cause - 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 thrown

      cause - the original exception that had caused the current one to be thrown

      detail - a detail object that will be serialized into JSON and sent to the client, when the exception is thrown

  • Method Details

    • 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 EndpointController. 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