package com.example.backend.exception;

import com.example.backend.common.ApiResponse;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局异常处理器
 */
@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(BizException.class)
    public ApiResponse<?> handleBiz(BizException ex) {
        return ApiResponse.fail(ex.getMessage());
    }
    @ExceptionHandler(Exception.class)
    public ApiResponse<?> handleOther(Exception ex) {
        return ApiResponse.fail("系统异常: " + ex.getMessage());
    }
} 