jeroenwijdemans / jaxrs-error-handling

Simple concrete classes for error handling in JAXRS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Work in progress

Codacy Badge Build Status License: MIT codecov

JAXRS Error handler

Exceptions thrown by JAXRS are serialized to strings (JSON for example) but not in a nice format. This library provides error mapping to a standardized Errors object or list.

  • Defines fixed error classes
  • Provides simple runtime exception handling in JAXRS.

Fixed classes makes sure that all applications use the same format across services.

TODO add support for XML

Dependencies

Expected the jackson library on the classpath:

  • com.fasterxml.jackson.jaxrs
  • com.fasterxml.jackson.jaxrs.annotations

Usage

Include dependency:

dependencies {
    compile "com.wijdemans:jaxrs-jetty-error-handling:0.0.1"
}

Add to container:

class Main {
    
    private ResourceConfig createResourceConfig () {
        
        final ResourceConfig rc = new ResourceConfig();
        rc.register(JaxRsErrorMapper.class);
        
        return rc;
    }  
        
}

Changelog

See changelog

About

Simple concrete classes for error handling in JAXRS

License:MIT License


Languages

Language:Java 82.2%Language:Groovy 10.1%Language:Shell 7.7%