mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-22 00:18:06 +01:00
Improve LoggingUnhandledExceptionMapper combination with CompletionExceptionMapper
This commit is contained in:
@@ -12,13 +12,13 @@ import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.ext.ExceptionMapper;
|
||||
import javax.ws.rs.ext.Provider;
|
||||
import javax.ws.rs.ext.Providers;
|
||||
import org.glassfish.jersey.spi.ExceptionMappers;
|
||||
|
||||
@Provider
|
||||
public class CompletionExceptionMapper implements ExceptionMapper<CompletionException> {
|
||||
|
||||
@Context
|
||||
private Providers providers;
|
||||
private ExceptionMappers exceptionMappers;
|
||||
|
||||
@Override
|
||||
public Response toResponse(final CompletionException exception) {
|
||||
@@ -26,8 +26,7 @@ public class CompletionExceptionMapper implements ExceptionMapper<CompletionExce
|
||||
|
||||
if (cause != null) {
|
||||
|
||||
final Class type = cause.getClass();
|
||||
final ExceptionMapper exceptionMapper = providers.getExceptionMapper(type);
|
||||
final ExceptionMapper exceptionMapper = exceptionMappers.findMapping(cause);
|
||||
|
||||
// some exception mappers, like LoggingExceptionMapper, have side effects (e.g., logging)
|
||||
// so we always build their response…
|
||||
|
||||
@@ -16,6 +16,9 @@ import org.whispersystems.textsecuregcm.util.ua.UnrecognizedUserAgentException;
|
||||
import org.whispersystems.textsecuregcm.util.ua.UserAgent;
|
||||
import org.whispersystems.textsecuregcm.util.ua.UserAgentUtil;
|
||||
|
||||
/**
|
||||
* Extends {@link LoggingExceptionMapper} to include the method and path in the log message, if they are available.
|
||||
*/
|
||||
public class LoggingUnhandledExceptionMapper extends LoggingExceptionMapper<Throwable> {
|
||||
|
||||
@Context
|
||||
|
||||
Reference in New Issue
Block a user