删除异常基类。应用系统应按实际需要自定义异常体系。

dev
ZhouXY108 2024-08-30 14:58:47 +08:00
parent 0b9635880e
commit 5e5202ff3a
6 changed files with 2 additions and 207 deletions

View File

@ -1,54 +0,0 @@
/*
* Copyright 2022-2023 the original author or authors.
*
* Licensed 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 xyz.zhouxy.plusone.commons.exception;
import javax.annotation.Nonnull;
import java.util.Objects;
/**
*
*
* @author <a href="http://zhouxy.xyz:3000/ZhouXY108">ZhouXY</a>
*/
public abstract class BaseException
extends Exception {
private static final long serialVersionUID = -2546365325001947203L;
@Nonnull
private final String type;
protected BaseException(String type, String msg) {
super(msg);
this.type = Objects.requireNonNull(type);
}
protected BaseException(String type, Throwable cause) {
super(cause);
this.type = Objects.requireNonNull(type);
}
protected BaseException(String type, String msg, Throwable cause) {
super(msg, cause);
this.type = Objects.requireNonNull(type);
}
@Nonnull
public final String getType() {
return this.type;
}
}

View File

@ -1,53 +0,0 @@
/*
* Copyright 2022-2023 the original author or authors.
*
* Licensed 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 xyz.zhouxy.plusone.commons.exception;
import javax.annotation.Nonnull;
import java.util.Objects;
/**
*
*
* @author <a href="http://zhouxy.xyz:3000/ZhouXY108">ZhouXY</a>
*/
public abstract class BaseRuntimeException extends RuntimeException {
private static final long serialVersionUID = -6345888403567792664L;
@Nonnull
private final String type;
protected BaseRuntimeException(String type, String msg) {
super(msg);
this.type = Objects.requireNonNull(type);
}
protected BaseRuntimeException(String type, Throwable cause) {
super(cause);
this.type = Objects.requireNonNull(type);
}
protected BaseRuntimeException(String type, String msg, Throwable cause) {
super(msg, cause);
this.type = Objects.requireNonNull(type);
}
@Nonnull
public final String getType() {
return this.type;
}
}

View File

@ -1,36 +0,0 @@
package xyz.zhouxy.plusone.commons.exception;
/**
*
*
* @author <a href="https://gitee.com/zhouxy108">ZhouXY</a>
*/
public class BizException extends BaseRuntimeException {
private static final long serialVersionUID = -5524759033245815405L;
protected BizException(String type, String msg) {
super(type, msg);
}
protected BizException(String type, Throwable cause) {
super(type, cause);
}
protected BizException(String type, String msg, Throwable cause) {
super(type, msg, cause);
}
private static final String DEFAULT = "0";
public static BizException of(String msg) {
return new BizException(DEFAULT, msg);
}
public static BizException of(Throwable cause) {
return new BizException(DEFAULT, cause);
}
public static BizException of(String msg, Throwable cause) {
return new BizException(DEFAULT, msg, cause);
}
}

View File

@ -1,31 +0,0 @@
package xyz.zhouxy.plusone.commons.exception;
public class SysException extends BaseRuntimeException {
private static final long serialVersionUID = 8821240827443168118L;
protected SysException(String type, String msg) {
super(type, msg);
}
protected SysException(String type, Throwable cause) {
super(type, cause);
}
protected SysException(String type, String msg, Throwable cause) {
super(type, msg, cause);
}
private static final String DEFAULT = "0";
public static SysException of(String msg) {
return new SysException(DEFAULT, msg);
}
public static SysException of(Throwable cause) {
return new SysException(DEFAULT, cause);
}
public static SysException of(String msg, Throwable cause) {
return new SysException(DEFAULT, msg, cause);
}
}

View File

@ -1,31 +0,0 @@
package xyz.zhouxy.plusone.commons.exception;
public class ThirdPartySystemException extends BaseRuntimeException {
private static final long serialVersionUID = 20240827113826L;
protected ThirdPartySystemException(String type, String msg) {
super(type, msg);
}
protected ThirdPartySystemException(String type, Throwable cause) {
super(type, cause);
}
protected ThirdPartySystemException(String type, String msg, Throwable cause) {
super(type, msg, cause);
}
private static final String DEFAULT = "0";
public static ThirdPartySystemException of(String msg) {
return new ThirdPartySystemException(DEFAULT, msg);
}
public static ThirdPartySystemException of(Throwable cause) {
return new ThirdPartySystemException(DEFAULT, cause);
}
public static ThirdPartySystemException of(String msg, Throwable cause) {
return new ThirdPartySystemException(DEFAULT, msg, cause);
}
}

View File

@ -5,14 +5,14 @@ import java.io.ObjectStreamClass;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import xyz.zhouxy.plusone.commons.exception.BaseRuntimeException; import xyz.zhouxy.plusone.commons.exception.NoAvailableMacFoundException;
@Slf4j @Slf4j
class SerialTests { class SerialTests {
@Test @Test
void testSerialVersionUID() { void testSerialVersionUID() {
long uid = getSerialVersionUID(BaseRuntimeException.class); long uid = getSerialVersionUID(NoAvailableMacFoundException.class);
log.info("\n private static final long serialVersionUID = {}L;", uid); log.info("\n private static final long serialVersionUID = {}L;", uid);
} }