first commit
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
package com.xuezhanmaster.common.api;
|
||||
|
||||
import com.xuezhanmaster.common.exception.BusinessException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
@RestControllerAdvice
|
||||
public class GlobalExceptionHandler {
|
||||
|
||||
@ExceptionHandler(BusinessException.class)
|
||||
public ApiResponse<Void> handleBusinessException(BusinessException exception) {
|
||||
return ApiResponse.failure(exception.getCode(), exception.getMessage());
|
||||
}
|
||||
|
||||
@ExceptionHandler(Exception.class)
|
||||
public ApiResponse<Void> handleGenericException(Exception exception) {
|
||||
return ApiResponse.failure("INTERNAL_ERROR", exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user