Last active
May 11, 2020 14:58
-
-
Save brunapereira/7e0ed5e3fc6de0825228557f0b1662bb to your computer and use it in GitHub Desktop.
Exception Handler
This file contains 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
@RestControllerAdvice | |
@Order(0) | |
class VendasExceptionHandler { | |
@ResponseStatus(BAD_REQUEST) | |
@ExceptionHandler(ProductNotFound::class) | |
fun onProductNotFound(e: ProductNotFound): ApiError { | |
log.error("error=product not found", e) | |
return ApiError(code = "PRODUCT_NOT_FOUND", message = e.message ?: "") | |
} | |
// other exceptions threatments.. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment