Package com.sodius.oslc.server
Class OslcWebApplicationException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
jakarta.ws.rs.WebApplicationException
com.sodius.oslc.server.OslcWebApplicationException
- All Implemented Interfaces:
Serializable
A WebApplicationException thats provides a message containing the HTTP status code and OSLC Error message, if any.
The super class WebApplicationException doesn't provide any message on its own, which doesn't help debugging.
This subclass is introduced to work around this.
- Since:
- 1.3.0
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionOslcWebApplicationException(Response response) Construct a new instance using the supplied response. -
Method Summary
Modifier and TypeMethodDescriptionReturns a message that contains the HTTP status code and OSLC Error message, if any.The list of causes of theOslcErrorentity of the response, or an empty list if no entity is set or it is not anOslcError.The entity of the response,nullif none.TheOslcErrorentity of the response,nullif no entity is set or it is not anOslcError.Methods inherited from class jakarta.ws.rs.WebApplicationException
getResponseMethods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
OslcWebApplicationException
Construct a new instance using the supplied response.Rather than directly instantiating this exception, developer is recommended to use
OslcResponses.of(OslcError, org.slf4j.Logger):OslcError error = OslcErrors.serverError(errorId, errorMessage).build(); throw OslcResponses.error(error, LOGGER).buildException();
The entity of the given response, if any, is kept locally in this instance and not communicated to super class. This enables an exception mapper (contributed by
OslcServerProviderRegistry) to be involved to stream the error entity withOslcStreams, rather than trusting the JAX-RS framework for this. ThegetResponseEntity()method may be used to retrieve the entity, if necessary, before it is serialized in the response stream.- Parameters:
response- the response that will be returned to the client.- See Also:
-
-
Method Details
-
getMessage
Returns a message that contains the HTTP status code and OSLC Error message, if any.- Overrides:
getMessagein classThrowable
-
getResponseEntity
The entity of the response,nullif none. The entity was detached from given response in constructor to control its serialization in actual response stream.- Returns:
- the response entity.
- Since:
- 1.13.0
-
getResponseError
TheOslcErrorentity of the response,nullif no entity is set or it is not anOslcError. This method is convenient on server side when a specific condition is to verify for an OSLC error resource used in this exception.- Returns:
- the response error.
- Since:
- 1.14.0
- See Also:
-
getResponseCauses
The list of causes of theOslcErrorentity of the response, or an empty list if no entity is set or it is not anOslcError. This method is convenient on server side when a specific condition is to verify for an OSLC error reported by an OSLC remote application.- Returns:
- the list of causes of the response error.
- Since:
- 1.14.0
- See Also:
-