You are here

class ErrorHelper in Commerce Mollie 8

Translates Mollie exceptions and errors into Commerce exceptions.

Hierarchy

Expanded class hierarchy of ErrorHelper

1 file declares its use of ErrorHelper
Mollie.php in src/Plugin/Commerce/PaymentGateway/Mollie.php

File

src/ErrorHelper.php, line 12

Namespace

Drupal\commerce_mollie
View source
class ErrorHelper {

  /**
   * Translates Mollie exceptions into Commerce exceptions.
   *
   * @param \Mollie\Api\Exceptions\ApiException $exception
   *   The Mollie exception.
   *
   * @throws \Drupal\commerce_payment\Exception\PaymentGatewayException
   *   The Commerce exception.
   */
  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());
    }
  }

  /**
   * Translates Mollie errors into Commerce exceptions.
   *
   * @param object $result
   *   The Mollie result object.
   *
   * @throws \Drupal\commerce_payment\Exception\PaymentGatewayException
   *   The Commerce exception.
   */
  public static function handleErrors($result) {
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ErrorHelper::handleErrors public static function Translates Mollie errors into Commerce exceptions.
ErrorHelper::handleException public static function Translates Mollie exceptions into Commerce exceptions.