/* * 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. */ package net.micode.notes.gtask.exception; // ActionFailureException类继承自RuntimeException,属于运行时异常,通常用于表示在执行某个操作时出现失败情况的异常类型。 // 这样的设计使得在代码中不需要显式地去捕获它(当然也可以捕获进行更精细的处理),方便在业务逻辑中遇到操作失败场景时抛出,以提示调用者操作未能成功完成。 public class ActionFailureException extends RuntimeException { // 用于实现Java序列化机制的版本号,保证在序列化和反序列化过程中对象的兼容性,这里是一个固定的长整型值。 private static final long serialVersionUID = 4425249765923293627L; // 默认构造函数,调用父类(RuntimeException)的默认构造函数,不传入任何特定的错误信息,创建一个简单的运行时异常实例。 public ActionFailureException() { super(); } // 构造函数,接受一个字符串参数,用于指定具体的错误信息内容,调用父类(RuntimeException)的对应构造函数,将错误信息传递给父类构造函数进行初始化。 // 这样在异常抛出后,调用者可以通过获取异常信息来了解操作失败的具体原因。 public ActionFailureException(String paramString) { super(paramString); } // 构造函数,接受一个字符串参数(用于指定具体的错误信息内容)和一个Throwable类型的参数(表示导致当前异常的根源异常,可能是另一个更低层的异常), // 调用父类(RuntimeException)的对应构造函数,将错误信息和根源异常传递给父类构造函数进行初始化。 // 方便在异常传播过程中保留原始异常信息,便于更准确地进行问题排查和调试。 public ActionFailureException(String paramString, Throwable paramThrowable) { super(paramString, paramThrowable); } }