Created
November 12, 2012 09:27
-
-
Save fehmicansaglam/4058355 to your computer and use it in GitHub Desktop.
Catch Interceptor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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