Created
April 11, 2018 15:44
-
-
Save kevin-madhu/f1c199830182947ccdfac11801be05d7 to your computer and use it in GitHub Desktop.
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
class CustomErrorWebExceptionHandler : AbstractErrorWebExceptionHandler() { | |
// Define constructor here | |
override fun getRoutingFunction(errorAttributes: ErrorAttributes): RouterFunction<ServerResponse> { | |
return RouterFunctions | |
.route<ServerResponse>(aPredicate, aHandler) | |
// .andRoute(anotherPredicate, anotherHandler) | |
.filter { request, next -> | |
try { | |
next.handle(request) | |
} catch (ex: Exception) { | |
when (ex) { | |
is ChangeSetPersister.NotFoundException -> ServerResponse.notFound().build() | |
else -> ServerResponse.status(HttpStatus.INTERNAL_SERVER_ERROR).build() | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment