All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.pighand.framework.spring.exception.ThrowException Maven / Gradle / Ivy

There is a newer version: 2.0.0-bate.2.20250103
Show newest version
package com.pighand.framework.spring.exception;

import jakarta.servlet.http.HttpServletResponse;

/**
 * 异常
 *
 * 

用法:throw new ThrowException() * *

异常信息优先级:全局配置.exception.message > 自定义 * *

即使配置类全局信息,日志依然显示正确错误信息 * * @author wangshuli */ public class ThrowException extends RuntimeException implements ThrowInterface { /** 异常消息 */ private final String error; /** 状态码默认500 */ private Integer code = HttpServletResponse.SC_INTERNAL_SERVER_ERROR; private Object data; public ThrowException(String error) { super(error); this.error = error; } public ThrowException(String error, Object data) { super(error); this.error = error; this.data = data; } /** * @param error * @param code */ public ThrowException(String error, Integer code) { super(error); this.error = error; this.code = code; } /** * @param error * @param code */ public ThrowException(String error, Integer code, Object data) { super(error); this.error = error; this.code = code; this.data = data; } @Override public Integer getCode() { return code; } @Override public Object getData() { return data; } @Override public String getError() { return error; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy