Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Powerful Tactic to Use Exception Mapper in Dropwizard

DZone's Guide to

Powerful Tactic to Use Exception Mapper in Dropwizard

When developing RESTful web services, people are often confused with handling exceptions. This post will explain a powerful tactic for using exception mapper with the Dropwizard framework.

· Integration Zone
Free Resource

Build APIs from SQL and NoSQL or Salesforce data sources in seconds. Read the Creating REST APIs white paper, brought to you in partnership with CA Technologies.

Dropwizard exception mapper

Problem

When developing RESTful web services, people are often confused with handling exceptions. This post will explain a powerful tactic for using exception mapper with the Dropwizard framework. JAX-RS specification has already introduced exception mappers for handling such a situation in a great way. We will see how this problem was addressed in an effective way by using Dropwizard infrastructure.

How?

Now we will see how we can address this problem by checking out some real code with Dropwizard framework.

There are three steps involved for achieving this:

  1. Introduce a custom exception
  2. Write an exception mapper for our newly introduced exception
  3. Throw the custom exception from our REST API

Custom Exception

Please share the article with your friends and provider your comments in the sidebar if any…

For a detailed code example refer https://github.com/cloudskol/dropwizardskol

Thank you!       

The Integration Zone is brought to you in partnership with CA Technologies.  Use CA Live API Creator to quickly create complete application backends, with secure APIs and robust application logic, in an easy to use interface.

Topics:
jax-rs ,rest api ,rest ,restful web services ,dropwizard ,framework ,api ,restful

Published at DZone with permission of Thamizh Arasu, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}