SecureApi DocumentSecureApi Document
Home
Get Start
Version History
  • China Mainland
  • International
  • 简体中文
  • English
Home
Get Start
Version History
  • China Mainland
  • International
  • 简体中文
  • English
  • Start
  • Guide

    • Install
    • Configuration
    • Try It
    • Annotation
    • Url Pattern
    • Exception Handle
    • Encryption Algorithm
    • CipherUtils
    • Two Modes
    • DH Key Agreement
    • Digital Signature Verification
  • Js Demo
  • Best Practice
  • Microservice Invocation
  • Black King Kong

Exception Handle

When SecureApi fails, it throws a specific exception: SecureApiException, You can customize the global exception handler to handle this exception.

Example:

@RestControllerAdvice
public class GlobalExceptionHandler {
    private final Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class);

    /**
     * Can be customized to handle SecureApi exceptions
     *
     * @param request request information
     * @param e       SecureApiException
     * @return Customize the return body, and the return result can also be encrypted here, if the url is configured to match /**, the return value will also be encrypted without comments
     */
    @ExceptionHandler(value = SecureApiException.class)
    //@EncryptApi
    public ResultEntity<Object> bizExceptionHandler(HttpServletRequest request, SecureApiException e) {
        logger.error("SecureApiException:{}", e.getErrorMsg());
        return ResultEntity.failure(500, e.getErrorMsg());
    }
}
Edit on GitHub
Last Updated:
Contributors: XuYijie
Prev
Url Pattern
Next
Encryption Algorithm