Example General Exception Mapper Apps
Plugin that adds general exception mapping capability
EOFException.class -> Status.BAD_REQUEST
JsonProcessingException.class -> Status.BAD_REQUESTImplement the interface com.aol.micro.server.general.exception.mapper.ExtensionMapOfExceptionsToErrorCodes in one of your Spring Beans.
@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;
}
}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'