Skip to content

Commit

Permalink
Rename BugsnagReporter class to ErrorUtils and update some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
evansiroky committed Jul 9, 2021
1 parent 1cc86ae commit 2e19ad4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.opentripplanner.api.common;

import org.opentripplanner.standalone.BugsnagReporter;
import org.opentripplanner.standalone.ErrorUtils;

import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
Expand All @@ -10,7 +10,7 @@
public class OTPExceptionMapper implements ExceptionMapper<Exception> {

public Response toResponse(Exception ex) {
BugsnagReporter.reportErrorToBugsnag("Unhandled server exception", ex);
ErrorUtils.reportErrorToBugsnag("Unhandled server exception", ex);

// Return the short form message to the client
return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import org.opentripplanner.api.common.Message;
import org.opentripplanner.routing.core.RoutingRequest;
import org.opentripplanner.routing.error.*;
import org.opentripplanner.standalone.BugsnagReporter;
import org.opentripplanner.standalone.ErrorUtils;

import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -41,7 +41,7 @@ public PlannerError(RoutingRequest req, Exception e) {
message = messages.get(e.getClass());
if (message == null) {
message = Message.SYSTEM_ERROR;
BugsnagReporter.reportErrorToBugsnag("Unhandled exception while planning trip", req, e);
ErrorUtils.reportErrorToBugsnag("Unhandled exception while planning trip", req, e);
}
this.setMsg(message);
if (e instanceof VertexNotFoundException)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
import org.slf4j.LoggerFactory;

/**
* Bugsnag util for reporting errors to the project defined by the Bugsnag project notifier API key.
* A util class for reporting errors to the project defined by the Bugsnag project notifier API key.
*
* A Bugsnag project identifier key is unique to a Bugsnag project and allows errors to be saved against it. This key
* can be obtained by logging into Bugsnag (https://app.bugsnag.com), clicking on Projects (left side menu) and
* selecting the required project. Once selected, the notifier API key is presented.
*/
public class BugsnagReporter {
public class ErrorUtils {
private static Bugsnag bugsnag;
private static final Logger LOG = LoggerFactory.getLogger(BugsnagReporter.class);
private static final Logger LOG = LoggerFactory.getLogger(ErrorUtils.class);

/**
* Initialize Bugsnag using the project notifier API key when the application is first loaded.
Expand Down Expand Up @@ -52,7 +52,7 @@ public static boolean reportErrorToBugsnag(String message, Object badEntity, Thr
// Log error to log output.
LOG.error(message, throwable);

// If bugsnag is disabled, make sure to report full error to otp-middleware logs.
// If bugsnag is disabled, make sure to report log full error.
if (bugsnag == null) {
LOG.warn("Bugsnag error reporting is disabled. Unable to report to Bugsnag this message: {} for this bad entity: {}",
message,
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/opentripplanner/standalone/OTPMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public static void main(String[] args) {
System.exit(-1);
}

BugsnagReporter.initializeBugsnagErrorReporting(params);
ErrorUtils.initializeBugsnagErrorReporting(params);

OTPMain main = new OTPMain(params);
if (!main.run()) {
Expand Down

0 comments on commit 2e19ad4

Please sign in to comment.