Cartalyst\Stripe\Exception\Handler::handleException PHP Method

handleException() protected method

Guesses the FQN of the exception to be thrown.
protected handleException ( string $message, integer $statusCode, string $errorType, string $errorCode, string $missingParameter ) : void
$message string
$statusCode integer
$errorType string
$errorCode string
$missingParameter string
return void
    protected function handleException($message, $statusCode, $errorType, $errorCode, $missingParameter)
    {
        if ($statusCode === 400 && $errorCode === 'rate_limit') {
            $class = 'ApiLimitExceeded';
        } elseif ($statusCode === 400 && $errorType === 'invalid_request_error') {
            $class = 'MissingParameter';
        } elseif (array_key_exists($errorType, $this->exceptionsByErrorType)) {
            $class = $this->exceptionsByErrorType[$errorType];
        } elseif (array_key_exists($statusCode, $this->exceptionsByStatusCode)) {
            $class = $this->exceptionsByStatusCode[$statusCode];
        } else {
            $class = 'Stripe';
        }
        $class = "\\Cartalyst\\Stripe\\Exception\\{$class}Exception";
        $instance = new $class($message, $statusCode);
        $instance->setErrorCode($errorCode);
        $instance->setErrorType($errorType);
        $instance->setMissingParameter($missingParameter);
        throw $instance;
    }