|
|
/*
|
|
|
* Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)
|
|
|
*
|
|
|
* 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
|
|
|
*
|
|
|
* http://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.
|
|
|
*/
|
|
|
|
|
|
// 包声明,表明该类位于net.micode.notes.gtask.exception包下,用于对特定业务逻辑中的异常情况进行统一管理和处理,这里主要和任务相关操作的异常有关(从包名推测)。
|
|
|
package net.micode.notes.gtask.exception;
|
|
|
|
|
|
// ActionFailureException类继承自RuntimeException,意味着它是一个运行时异常,不需要在编译时显式地被捕获或者声明抛出(当然也可以根据需要进行捕获处理)。
|
|
|
// 该类主要用于表示在任务相关操作(比如创建、更新任务等操作,从使用场景推测)中出现失败情况时抛出的异常,方便在业务逻辑中区分不同类型的异常情况并进行针对性处理。
|
|
|
public class ActionFailureException extends RuntimeException {
|
|
|
// 定义一个序列化版本号,用于在对象序列化和反序列化过程中保证版本兼容性,这个值是根据Java的序列化机制要求生成的一个固定的长整型数字,
|
|
|
// 当类的结构发生变化(如添加、删除成员变量等情况)时,可能需要相应地更新这个版本号,以避免反序列化出现问题,但如果类结构稳定,通常保持这个初始值即可。
|
|
|
private static final long serialVersionUID = 4425249765923293627L;
|
|
|
|
|
|
// 无参构造函数,调用父类(RuntimeException)的无参构造函数,用于创建一个默认的ActionFailureException实例,
|
|
|
// 当在业务逻辑中不需要指定具体的异常信息时,可以使用这个构造函数创建异常对象并抛出,不过通常这种情况较少,更多是希望传递一些描述失败原因的信息。
|
|
|
public ActionFailureException() {
|
|
|
super();
|
|
|
}
|
|
|
|
|
|
// 带有一个字符串参数的构造函数,接收一个表示异常详细信息的字符串(paramString),调用父类(RuntimeException)相应的构造函数,
|
|
|
// 将该字符串作为异常信息传递进去,用于创建一个带有具体描述信息的ActionFailureException实例,方便在抛出异常时告知调用者具体的失败原因,
|
|
|
// 比如在任务创建操作失败时,可以传递类似"创建任务时参数不合法"这样的信息,便于定位问题。
|
|
|
public ActionFailureException(String paramString) {
|
|
|
super(paramString);
|
|
|
}
|
|
|
|
|
|
// 带有一个字符串参数和一个Throwable参数的构造函数,接收一个表示异常详细信息的字符串(paramString)以及一个表示引起当前异常的根异常对象(paramThrowable),
|
|
|
// 调用父类(RuntimeException)相应的构造函数,将这两个参数传递进去,用于创建一个既包含具体描述信息又关联了引起当前异常的底层异常的ActionFailureException实例,
|
|
|
// 例如在任务更新操作因为数据库连接异常而失败时,可以传递类似"更新任务时数据库连接失败"作为paramString,同时将数据库连接相关的异常对象作为paramThrowable传入,
|
|
|
// 这样在排查问题时可以通过获取根异常信息更全面地了解导致操作失败的原因。
|
|
|
public ActionFailureException(String paramString, Throwable paramThrowable) {
|
|
|
super(paramString, paramThrowable);
|
|
|
}
|
|
|
} |