All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hubspot.singularity.sentry.NotifyingExceptionMapper Maven / Gradle / Ivy

package com.hubspot.singularity.sentry;

import javax.ws.rs.core.Response;

import com.google.inject.Inject;

import io.dropwizard.jersey.errors.LoggingExceptionMapper;

@javax.ws.rs.ext.Provider
public class NotifyingExceptionMapper extends LoggingExceptionMapper {
  private final SingularityExceptionNotifier notifier;

  @Inject
  public NotifyingExceptionMapper(SingularityExceptionNotifier notifier) {
    this.notifier = notifier;
  }

  @Override
  public Response toResponse(final Exception e) {
    final Response response = super.toResponse(e);

    if (response.getStatus() >= 500) {
      notifier.notify(String.format("Uncaught Exception (%s)", e.getMessage()), e);
    }

    return response;
  }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy