Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CIRC-2212: Log the stack trace and message for all 500 errors #1528

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,25 @@

import static org.folio.circulation.support.results.Result.failed;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.folio.circulation.support.ServerErrorFailure;

import java.lang.invoke.MethodHandles;

public class CommonFailures {
private static final Logger log = LogManager.getLogger(MethodHandles.lookup().lookupClass());
private static final String INTERNAL_SERVER_ERROR = "Internal Server Error";

private CommonFailures() {}

public static <T> Result<T> failedDueToServerError(Throwable e) {
log.error(INTERNAL_SERVER_ERROR, e);
return failed(new ServerErrorFailure(e));
}

public static <T> Result<T> failedDueToServerError(String reason) {
log.error(INTERNAL_SERVER_ERROR, new Throwable(reason));
return failed(new ServerErrorFailure(reason));
}
}