package com.bizzan.bitrade.controller.common;

import com.bizzan.bitrade.util.MessageResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
@Slf4j
public class GlobalController {

    @ExceptionHandler({Exception.class})
    @ResponseBody
    public MessageResult exception(Exception e) {
        log.error("全局异常捕获: {}", e.getMessage(), e);
        return MessageResult.error("系统内部错误: " + e.getMessage());
    }
}
