Exception handling - 2Parale/2Performant-php GitHub Wiki

The methods throw exceptions that are all sub-classes of the \TPerformant\API\Exception\TPException super-class.

  • InvalidResponseException (extends APIException) - thrown when the API response cannot be parsed as valid JSON
  • ClientException (extends APIException) - thrown when the server receives invalid user input and returns a 4XX status code (other than authentication-related issues)
  • ServerException (extends APIException) - thrown when the server encountered an internal error and returns a 5XX status code
  • APIException (extends TPException) - thrown in case of an authentication error or some other generic API issue
  • ConnectionException (extends TransferException) - thrown when the connection to the API server was initiated, but a networking error occurred
  • TransferException (extends TPException) - thrown when the connection to the API server could not be initiated
  • TPException - generic exception

You should wrap your code in try..catch blocks in order to prevent issues.

try {
    $me->getCommissions();
} catch(\TPerformant\API\Exception\TPException) {
    // handle error
}