whh
4 months ago
2 changed files with 19 additions and 2 deletions
@ -0,0 +1,17 @@ |
|||||
|
package com.haihang.config; |
||||
|
|
||||
|
import com.haihang.utils.Result; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.web.bind.annotation.ExceptionHandler; |
||||
|
import org.springframework.web.bind.annotation.RestControllerAdvice; |
||||
|
|
||||
|
@Slf4j |
||||
|
@RestControllerAdvice |
||||
|
public class WebExceptionAdvice { |
||||
|
|
||||
|
@ExceptionHandler(RuntimeException.class) |
||||
|
public Result handleRuntimeException(RuntimeException e) { |
||||
|
log.error(e.toString(), e); |
||||
|
return Result.fail("服务器异常:"+e.getMessage()); |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue