package com.nokia.domainb.exception;

import com.nokia.common.http.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 请求异常处理
 */
@Slf4j
@RestControllerAdvice
public class ControllerExceptionHandler
{
    @SuppressWarnings("rawtypes")
    @ExceptionHandler({Exception.class})
    public ResponseEntity exceptionHandler(Exception e)
    {
        log.error("╭( ′• o •′ )╭☞ 发生错误了 {}", e.getMessage(), e);
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(R.error().message(e.getMessage()));
    }
}
