java-tutorials/api-error-handling/hello-controller-advice
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 | |
public class HelloControllerAdvice { | |
@ExceptionHandler(Exception.class) | |
public ApiError handleGeneralException(){ | |
return ApiError.builder() | |
.error("General Error (from controller-advice)") | |
.errorCode(500) | |
.build(); | |
} | |
@ExceptionHandler(SyntaxException.class) | |
public ApiError handleSyntaxException(){ | |
return ApiError.builder() | |
.error("Syntax Error (from controller-advice)") | |
.errorCode(991) | |
.build(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment