RESTEasy Exception Chains

Library for serializing exceptions and relaying them to a client

License

License

Categories

Categories

RESTEasy Program Interface REST Frameworks
GroupId

GroupId

uk.ac.cam.cl.dtg.web
ArtifactId

ArtifactId

resteasy-exception-chains
Last Version

Last Version

1.0.10
Release Date

Release Date

Type

Type

jar
Description

Description

RESTEasy Exception Chains
Library for serializing exceptions and relaying them to a client
Project URL

Project URL

https://github.com/ucam-cl-dtg/resteasy-exception-chains
Source Code Management

Source Code Management

https://github.com/ucam-cl-dtg/resteasy-exception-chains.git

Download resteasy-exception-chains

How to add to project

<!-- https://jarcasting.com/artifacts/uk.ac.cam.cl.dtg.web/resteasy-exception-chains/ -->
<dependency>
    <groupId>uk.ac.cam.cl.dtg.web</groupId>
    <artifactId>resteasy-exception-chains</artifactId>
    <version>1.0.10</version>
</dependency>
// https://jarcasting.com/artifacts/uk.ac.cam.cl.dtg.web/resteasy-exception-chains/
implementation 'uk.ac.cam.cl.dtg.web:resteasy-exception-chains:1.0.10'
// https://jarcasting.com/artifacts/uk.ac.cam.cl.dtg.web/resteasy-exception-chains/
implementation ("uk.ac.cam.cl.dtg.web:resteasy-exception-chains:1.0.10")
'uk.ac.cam.cl.dtg.web:resteasy-exception-chains:jar:1.0.10'
<dependency org="uk.ac.cam.cl.dtg.web" name="resteasy-exception-chains" rev="1.0.10">
  <artifact name="resteasy-exception-chains" type="jar" />
</dependency>
@Grapes(
@Grab(group='uk.ac.cam.cl.dtg.web', module='resteasy-exception-chains', version='1.0.10')
)
libraryDependencies += "uk.ac.cam.cl.dtg.web" % "resteasy-exception-chains" % "1.0.10"
[uk.ac.cam.cl.dtg.web/resteasy-exception-chains "1.0.10"]

Dependencies

compile (3)

Group / Artifact Type Version
org.jboss.resteasy : resteasy-jaxrs jar 3.0.8.Final
org.jboss.resteasy : resteasy-jackson2-provider jar 3.0.8.Final
org.slf4j : slf4j-api jar 1.7.7

provided (1)

Group / Artifact Type Version
javax.servlet : javax.servlet-api jar 3.0.1

test (1)

Group / Artifact Type Version
junit : junit jar 3.8.1

Project Modules

There are no modules declared in this project.

resteasy-exception-chains

This is a small library to provide a uniform mechanism for throwing and catching exceptions through a resteasy api. The intention is to standardise error handling within applications and to make debugging easier by propagating remote errors all the way back to the client.

The central idea is provided by the SerializableException class. This class implements Exception and is designed to be seralizable to and from JSON (you can't do this with a normal exception class). Users of this library should register the ExceptionHandler class with their resteasy application. ExceptionHandler is responsible for catching all Throwables from the application, wrapping them in SerializableException and passing this to the client.

One benefit of a standardised serialised exception is that you can automatically chain exception information across remote API calls. You do this by registering RemoteFailureHandler with your application. For example:

    ResteasyClient c = new ResteasyClientBuilder().build();
    ResteasyWebTarget t = c.target("http://remote.com/api");
    ExampleApi proxy = t.proxy(ExampleApi.class);
    Item item = proxy.fetchItem("item1");
    return item;

When the proxy call is made we cause the remote server to execute code. If this throws an exception this is serialised into JSON and returned to us. This causes the proxy object to throw an exception which is captured in turn by RemoteFailureHandler. RemoteFailureHandler then extracts the original cause and serialises a further exception to return to the client.

Usage

Include this library in your class path and register ExceptionHandler and RemoteFailureHandler with your application.

uk.ac.cam.cl.dtg.web

Digital Technology Group, Computer Laboratory, University of Cambridge

Versions

Version
1.0.10