diff --git a/src/main/java/com/gszc/controller/ExceptionController.java b/src/main/java/com/gszc/controller/ExceptionController.java new file mode 100644 index 0000000..d0eff1e --- /dev/null +++ b/src/main/java/com/gszc/controller/ExceptionController.java @@ -0,0 +1,17 @@ +package com.gszc.controller; + +import com.gszc.build.Result; +import com.gszc.build.ResultBuilder; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseBody; + +@ControllerAdvice +public class ExceptionController { + + @ResponseBody + @ExceptionHandler(Exception.class) + public Result runtimeExceptionHandler(Exception e) { + return ResultBuilder.error(e.getMessage(),e).build(); + } +} \ No newline at end of file