You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
rass/gtask/exception/NetworkFailureException.java

42 lines
2.7 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/*
* 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;
// NetworkFailureException类继承自Exception属于受检异常Checked Exception意味着在代码中使用到可能抛出该异常的方法时
// 必须显式地使用try-catch语句进行捕获处理或者在方法声明中使用throws关键字将异常继续向上抛出用于表示在网络相关操作出现失败情况时的异常类型。
public class NetworkFailureException extends Exception {
// 用于实现Java序列化机制的版本号保证在序列化和反序列化过程中对象的兼容性这里是一个固定的长整型值。
private static final long serialVersionUID = 2107610287180234136L;
// 默认构造函数调用父类Exception的默认构造函数不传入任何特定的错误信息创建一个简单的异常实例通常在不需要详细错误描述时使用。
public NetworkFailureException() {
super();
}
// 构造函数接受一个字符串参数用于指定具体的错误信息内容调用父类Exception的对应构造函数将错误信息传递给父类构造函数进行初始化。
// 这样在抛出该异常后,捕获异常的代码可以通过获取异常信息来了解网络操作失败的具体原因。
public NetworkFailureException(String paramString) {
super(paramString);
}
// 构造函数接受一个字符串参数用于指定具体的错误信息内容和一个Throwable类型的参数表示导致当前异常的根源异常可能是另一个更低层的异常
// 调用父类Exception的对应构造函数将错误信息和根源异常传递给父类构造函数进行初始化。
// 方便在异常传播过程中保留原始异常信息便于更准确地进行问题排查和调试例如网络请求底层出现IOException等异常时可以将其作为根源异常传递上来。
public NetworkFailureException(String paramString, Throwable paramThrowable) {
super(paramString, paramThrowable);
}
}