Class SmsNetworkException

All Implemented Interfaces:
Serializable

public class SmsNetworkException extends SmsException
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 Details

  • Method Details

    • getHost

      public String getHost()
      Gets the target host 获取目标主机
      Returns:
      host | 主机
    • 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

      public static SmsNetworkException networkError(String host, Throwable cause)
      Creates a network error exception 创建网络错误异常
      Parameters:
      host - target host | 目标主机
      cause - original exception | 原始异常
      Returns:
      network exception | 网络异常
    • networkError

      public static SmsNetworkException networkError(URI uri, Throwable cause)
      Creates a network error exception for a URI 为URI创建网络错误异常
      Parameters:
      uri - target URI | 目标URI
      cause - original exception | 原始异常
      Returns:
      network exception | 网络异常
    • httpError

      public static SmsNetworkException httpError(String host, int statusCode, String body)
      Creates an HTTP error exception 创建HTTP错误异常
      Parameters:
      host - target host | 目标主机
      statusCode - HTTP status code | HTTP状态码
      body - response body | 响应体
      Returns:
      network exception | 网络异常
    • connectionRefused

      public static SmsNetworkException connectionRefused(String host, int port)
      Creates a connection refused exception 创建连接被拒绝异常
      Parameters:
      host - target host | 目标主机
      port - target port | 目标端口
      Returns:
      network exception | 网络异常