Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

readme.md

General Exception Mapper Plugin Plugin

Example General Exception Mapper Apps

Plugin that adds general exception mapping capability

The default mappings

EOFException.class ->  Status.BAD_REQUEST
JsonProcessingException.class ->  Status.BAD_REQUEST

Custom Extensions

Implement the interface com.aol.micro.server.general.exception.mapper.ExtensionMapOfExceptionsToErrorCodes in one of your Spring Beans.

Example custom extension

@Component
public class MappingExtension implements ExtensionMapOfExceptionsToErrorCodes {

	@Override
	public LinkedHashMap<Class<? extends Exception>, Tuple2<String, Status>> getErrorMappings() {
		LinkedHashMap<Class<? extends Exception>, Tuple2<String, Status>> map = new LinkedHashMap<>();
		map.put(MyException.class, Tuple.tuple("my-error",Status.BAD_GATEWAY));
		return map;
	}

}

To use

Maven Central

Simply add to the classpath

Maven

     <dependency>
        <groupId>com.aol.microservices</groupId>  
        <artifactId>micro-general-exception-mapper</artifactId>
        <version>x.yz</version>
     </dependency>

Gradle

    compile 'com.aol.microservices:micro-general-exception-mapper:x.yz'