Skip to content
Snippets Groups Projects
Commit d9814937 authored by Thorsten Vitt's avatar Thorsten Vitt
Browse files

log exceptions

parent fa28bfd3
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,8 @@
import java.text.MessageFormat;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;
......@@ -22,6 +24,8 @@
import com.google.common.collect.ImmutableMap;
public class GenericExceptionMapper implements ExceptionMapper<Exception> {
Logger logger = Logger.getLogger("info.textgrid.services.aggregator");
public static final Map<Class<? extends Exception>, Response.Status> STATUS_MAP = ImmutableMap
.<Class<? extends Exception>, Response.Status> builder()
.put(MetadataParseFault.class, Status.BAD_REQUEST)
......@@ -75,6 +79,12 @@ public Response toResponse(final Exception exception) {
.getStatusCode(), status.getReasonPhrase(), HtmlUtils
.htmlEscapeHex(message), HtmlUtils
.htmlEscapeHex(Throwables.getStackTraceAsString(exception))));
logger.log(Level.WARNING, MessageFormat.format(
"Caught {0}: {1}, returned {2} {3}", exception.getClass()
.getSimpleName(), exception.getMessage(), status
.getStatusCode(), status.getReasonPhrase()), exception);
return builder.build();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment