# Exceptions Example

This example demonstrates how to throw and map exceptions using ExceptionMapper in Jersey resource classes.

## Contents

The example consists of just one Jersey resource:

`com.sun.jersey.samples.exceptions.MyResource`
  that produces a simple textual response to an HTTP GET
  and contains a bunch of sub-resource methods demonstrating
  various exception processing scenarios

The mapping of the URI path space is presented in the following table:

URI path | Resource class | HTTP methods
--- | --- | ---
/myresource | MyResource | GET
/myresource/runtime | MyResource | GET
/myresource/checked/ioexception | MyResource | GET
/myresource/checked/mymappedexception | MyResource | GET
/myresource/checked/mymappedruntimeexception | MyResource | GET
/myresource/checked/mymappedthrowingexception | MyResource | GET
/myresource/webapplicationexception/{status} | MyResource | GET

## Running the Example

Run the example as follows:

run

> `mvn clean compile exec:java`

From a web browser, visit:

> `http://localhost:9998/myresource`

> `http://localhost:9998/myresource/runtime?ex=java.lang.NullPointerException` (see stack trace)

> `http://localhost:9998/myresource/checked/ioexception` (see stack trace)

> `http://localhost:9998/myresource/checked/mymappedexception`

> `http://localhost:9998/myresource/checked/mymappedruntimeexception`

> `http://localhost:9998/myresource/checked/mymappedthrowingexception` (see stack trace)

> `http://localhost:9998/myresource/webapplicationexception/505?r=errrrorMsg` (see stacktrace)

Where suggested see stack trace for details on exception processing.