getSecretKey jsonResult getNoteTxt
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package com.flagnote.note.utils;
|
||||
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
@RestControllerAdvice
|
||||
public class GlobalExceptionHandler {
|
||||
|
||||
@ExceptionHandler(RuntimeException.class)
|
||||
public Object businessExceptionHandler(HttpServletRequest request,HttpServletResponse response,Exception e)
|
||||
{
|
||||
log.error("ExceptionHandler(RuntimeException.class)",e);
|
||||
JsonResult jsonResult = new JsonResult();
|
||||
String message = e.getMessage();
|
||||
if (null!=message && message.matches("^E:\\d{6}$")) {
|
||||
jsonResult.setCode(message.substring(2, 8));
|
||||
}else {
|
||||
jsonResult.setCode("800000");
|
||||
}
|
||||
jsonResult.setMessage("business exception");
|
||||
return jsonResult;
|
||||
}
|
||||
|
||||
@ExceptionHandler(Exception.class)
|
||||
public Object exceptionHandler(HttpServletRequest request,HttpServletResponse response,Exception e)
|
||||
{
|
||||
log.error("ExceptionHandler(Exception.class)",e);
|
||||
JsonResult jsonResult = new JsonResult();
|
||||
jsonResult.setCode("900000");
|
||||
jsonResult.setMessage("exception");
|
||||
return jsonResult;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user