
com.zoomlion.cloud.common.handler.GlobalControllerExceptionHandler Maven / Gradle / Ivy
The newest version!
package com.zoomlion.cloud.common.handler;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import com.zoomlion.cloud.common.exception.BusinessServiceException;
import com.zoomlion.cloud.common.response.BusinessServiceErrorResponse;
import com.zoomlion.cloud.common.response.CommonErrorResponse;
@RestControllerAdvice
public class GlobalControllerExceptionHandler {
@ExceptionHandler(value = { BusinessServiceException.class })
@ResponseStatus(HttpStatus.OK)
public BusinessServiceErrorResponse businessServiceException(BusinessServiceException ex) {
return new BusinessServiceErrorResponse(ex.getClazz(), ex.getErrorCode() , ex.getParams());
}
@ExceptionHandler(value = { RuntimeException.class, Exception.class })
@ResponseStatus(HttpStatus.OK)
public CommonErrorResponse exception(Exception ex) {
return new CommonErrorResponse(ex);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy