- Documentation
Torch Object Storage
SDK Reference
Java
Exception Handling (Java SDK)
Java
Exception Handling (Java SDK)
Exception Handling (Java SDK)
This document introduces exception handling when using the TOS SDK.
TOS Server-Side Error
SDK Custom Exception
The TOS Java SDK defines two types of exceptions: TosClientException for client-side errors and TosServerException for server-side errors. Both exception classes inherit from TosException, which in turn extends RuntimeException.
Client-Side Exception: TosClientException
A TosClientException is typically thrown before the SDK sends a request to the TOS server. The following are scenarios in which this exception may be raised.
- Parameter validation failed. For example, when the parameters of the XXInput class are empty or the bucket name is non-compliant (such as when the bucket name exceeds 63 characters), etc.
- Transmission failures may occur during upload or download processes due to network anomalies, program interruptions, and other similar issues.
If a TosClientException occurs, it is recommended to first verify that the input parameters comply with the specifications. The TosClientException records the cause of the exception in its message, which can be obtained and analyzed using the TosClientException.getMessage() method.
Server-Side Exception: TosServerException
Exception Handling Examples
For handling TosClientException and TosServerException thrown by the SDK, please refer to the Client General Example for details. Last updated: 2025.09.19 20:00:28