package com.jkcredit.invoice.hub.config;

import com.jkcredit.invoice.hub.constant.CommonConstant;
import com.jkcredit.invoice.hub.constant.ResponseStatus;
import com.jkcredit.invoice.hub.model.vo.common.AppResponseVo;
import com.jkcredit.invoice.hub.spi.lang.exception.ServiceException;
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.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.util.Collections;

/**
 * @description:
 * @author: xusonglin
 * @create: 2020/1/9 21:29
 * @version: V1.0
 **/
@Slf4j
@RestControllerAdvice
public class ControllerAdvice {

    @ExceptionHandler(value = Exception.class)
    public ResponseEntity<AppResponseVo> errorHandler(ServiceException ex) {
        return ResponseEntity.ok(new AppResponseVo(ResponseStatus.FAILED, ex.getMessage(), null));
    }

}
