Class SmsNetworkException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
cloud.opencode.base.sms.exception.SmsException
cloud.opencode.base.sms.exception.SmsNetworkException
- All Implemented Interfaces:
Serializable
SMS Network Exception
短信网络异常
Exception thrown when network errors occur during SMS operations.
短信操作期间发生网络错误时抛出的异常。
Features | 主要功能:
- Host and port tracking for diagnostics - 主机和端口跟踪用于诊断
- HTTP status code capture - HTTP状态码捕获
Usage Examples | 使用示例:
throw new SmsNetworkException(SmsErrorCode.NETWORK_ERROR, "api.example.com", cause);
Security | 安全性:
- Thread-safe: Yes (immutable after construction) - 线程安全: 是(构造后不可变)
- Since:
- JDK 25, opencode-base-sms V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSmsNetworkException(SmsErrorCode errorCode, String host) SmsNetworkException(SmsErrorCode errorCode, String host, int port) SmsNetworkException(SmsErrorCode errorCode, String host, int statusCode, String message) SmsNetworkException(SmsErrorCode errorCode, String host, Throwable cause) -
Method Summary
Modifier and TypeMethodDescriptionstatic SmsNetworkExceptionconnectionRefused(String host, int port) Creates a connection refused exception 创建连接被拒绝异常getHost()Gets the target host 获取目标主机intgetPort()Gets the target port 获取目标端口intGets the HTTP status code 获取HTTP状态码static SmsNetworkExceptionCreates an HTTP error exception 创建HTTP错误异常static SmsNetworkExceptionnetworkError(String host, Throwable cause) Creates a network error exception 创建网络错误异常static SmsNetworkExceptionnetworkError(URI uri, Throwable cause) Creates a network error exception for a URI 为URI创建网络错误异常Methods inherited from class SmsException
getCode, getErrorCodeMethods inherited from class Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
SmsNetworkException
-
SmsNetworkException
-
SmsNetworkException
-
SmsNetworkException
-
-
Method Details
-
getHost
-
getPort
public int getPort()Gets the target port 获取目标端口- Returns:
- port or -1 if not applicable | 端口,如果不适用则为-1
-
getStatusCode
public int getStatusCode()Gets the HTTP status code 获取HTTP状态码- Returns:
- status code or -1 if not applicable | 状态码,如果不适用则为-1
-
networkError
Creates a network error exception 创建网络错误异常- Parameters:
host- target host | 目标主机cause- original exception | 原始异常- Returns:
- network exception | 网络异常
-
networkError
Creates a network error exception for a URI 为URI创建网络错误异常- Parameters:
uri- target URI | 目标URIcause- original exception | 原始异常- Returns:
- network exception | 网络异常
-
httpError
Creates an HTTP error exception 创建HTTP错误异常- Parameters:
host- target host | 目标主机statusCode- HTTP status code | HTTP状态码body- response body | 响应体- Returns:
- network exception | 网络异常
-
connectionRefused
Creates a connection refused exception 创建连接被拒绝异常- Parameters:
host- target host | 目标主机port- target port | 目标端口- Returns:
- network exception | 网络异常
-