package com.emergencyrepair.common;
|
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
|
@RestControllerAdvice
|
public class GlobalExceptionHandler {
|
@ExceptionHandler(BusinessException.class)
|
public Result<Void> handleBusiness(BusinessException exception) {
|
return Result.error(exception.getMessage());
|
}
|
|
@ExceptionHandler(Exception.class)
|
public Result<Void> handleOther(Exception exception) {
|
exception.printStackTrace();
|
return Result.error(exception.getMessage() == null ? "系统异常" : exception.getMessage());
|
}
|
}
|