* @license MIT License * @link https://github.com/your-repo/spacetraders */ /** * Custom exception class for Spacetraders API related errors. * * This exception is thrown when API calls to the Spacetraders service * encounter errors such as network issues, invalid responses, authentication * failures, or other API-specific problems. * * @extends RuntimeException */ class SpacetradersApiException extends RuntimeException { /** * Error payload data from the API response. * * @var array */ protected array $errorPayload = array(); /** * Constructor for SpacetradersApiException. * * @param string $message The exception message. * @param int $code The exception code (default: 0). * @param array $errorPayload The error payload from API response (default: empty array). */ public function __construct( string $message, int $code = 0, array $errorPayload = array() ) { parent::__construct( $message, $code ); $this->errorPayload = $errorPayload; } /** * Get the error payload from the API response. * * @return array */ public function getErrorPayload(): array { return $this->errorPayload; } }