You are here

public static function ErrorHelper::handleException in Commerce Mollie 8

Translates Mollie exceptions into Commerce exceptions.

Parameters

\Mollie\Api\Exceptions\ApiException $exception: The Mollie exception.

Throws

\Drupal\commerce_payment\Exception\PaymentGatewayException The Commerce exception.

2 calls to ErrorHelper::handleException()
Mollie::createRemotePayment in src/Plugin/Commerce/PaymentGateway/Mollie.php
Mollie::__construct in src/Plugin/Commerce/PaymentGateway/Mollie.php
Constructs a new PaymentGatewayBase object.

File

src/ErrorHelper.php, line 23

Class

ErrorHelper
Translates Mollie exceptions and errors into Commerce exceptions.

Namespace

Drupal\commerce_mollie

Code

public static function handleException(MollieApiException $exception) {
  if ('Invalid API key' === substr($exception
    ->getMessage(), 0, 15)) {
    throw new AuthenticationException($exception
      ->getMessage());
  }
  else {
    throw new InvalidResponseException($exception
      ->getMessage());
  }
}