Search in sources :

Example 1 with TryCatch

use of com.tvd12.ezyhttp.server.core.annotation.TryCatch in project ezyhttp by youngmonkeys.

the class GlobalExceptionHandler method handleException.

@TryCatch(InvalidFormatException.class)
public void handleException(RequestArguments args, HttpServletRequest request, HttpServletResponse response, InvalidFormatException e) {
    e.printStackTrace();
    Map<String, String> data = new HashMap<>();
    for (Reference reference : e.getPath()) data.put(reference.getFieldName(), "invalid");
    throw new HttpBadRequestException(data);
}
Also used : HashMap(java.util.HashMap) Reference(com.fasterxml.jackson.databind.JsonMappingException.Reference) HttpBadRequestException(com.tvd12.ezyhttp.core.exception.HttpBadRequestException) TryCatch(com.tvd12.ezyhttp.server.core.annotation.TryCatch)

Aggregations

Reference (com.fasterxml.jackson.databind.JsonMappingException.Reference)1 HttpBadRequestException (com.tvd12.ezyhttp.core.exception.HttpBadRequestException)1 TryCatch (com.tvd12.ezyhttp.server.core.annotation.TryCatch)1 HashMap (java.util.HashMap)1