
com.lodsve.boot.component.webmvc.response.LodsveBootExceptionHandler Maven / Gradle / Ivy
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.lodsve.boot.component.webmvc.response;
import com.lodsve.boot.bean.WebResult;
import com.lodsve.boot.exception.LodsveBootException;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
/**
* 统一异常处理,这些异常说明是业务无法处理,区分statusCode供前端使用不同方式处理。
*
* @author sunhao([email protected])
*/
@ControllerAdvice(annotations = RestController.class)
public class LodsveBootExceptionHandler {
private static final Logger logger = LoggerFactory.getLogger(LodsveBootExceptionHandler.class);
/**
* 捕获自定义异常
*/
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(LodsveBootException.class)
@ResponseBody
public WebResult
© 2015 - 2025 Weber Informatics LLC | Privacy Policy