Package org.stellar.sdk.exception


package org.stellar.sdk.exception
Exceptions that can be thrown by the Stellar SDK.

The base exception class is SdkException, which extends RuntimeException. Most exceptions thrown by the SDK extend SdkException, while some extend IllegalArgumentException directly.

The Stellar SDK uses unchecked exceptions (extending RuntimeException) for the following reasons:

  • Stellar SDK methods may throw exceptions as a result of errors that occur in the Stellar network, which are out of the control of the SDK itself. Forcing developers to catch such exceptions would lead to cluttered code.
  • Most methods in the SDK throw exceptions to indicate errors that cannot be handled by the method itself. Propagating these exceptions as unchecked exceptions allows developers to handle them at an appropriate point in their code.
  • Unchecked exceptions are more suitable for an API like the Stellar SDK, where most exceptions indicate programming errors or errors in interaction with the Stellar network, rather than recoverable conditions.

While the SDK uses unchecked exceptions, developers are still encouraged to catch and handle these exceptions appropriately in their code. The specific exception classes thrown by the SDK provide useful information about the nature of the error that occurred.

See Also: