Skip to content

Instantly share code, notes, and snippets.

@fehmicansaglam
Created November 12, 2012 09:27
Show Gist options
  • Save fehmicansaglam/4058355 to your computer and use it in GitHub Desktop.
Save fehmicansaglam/4058355 to your computer and use it in GitHub Desktop.
Catch Interceptor
@Catch
static void exception(Throwable t) {
// Hatayı logla
Logger.error(ExceptionUtils.getStackTrace(t));
// Dönüş mesajını oluştur
Throwable cause = t.getCause();
String message = null;
if (cause != null && cause instanceof ConstraintViolationException) {
message = "constraint violation";
} else if(....) {
message = "....";
} else {
message = t.getMessage();
}
// Hatayı MongoDB'ye yaz
// ....
// Mesajı dön
error(500, message != null ? message : "bilinmeyen hata");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment