Make exception.

@param  int     $errorCode
@param  string  $errorMessage

@return mixed
199302
public static function make($errorCode, $errorMessage)
    {
        $exception = Arr::get(self::$supported, $errorCode, Errors\Error::class);

        return new $exception($errorMessage, $errorCode);
    }
758290
protected function FillInstance($errorId, $errorMessage, $exception) {
        $this->errorId = $errorId;
        $this->errorMessage = $errorMessage;
        $this->exceptionObj = $exception;
    }
143238
static public function createWithSafeMessage($safeMessage = "", array $messageData = array(), $code = 0, \Exception $previous = null)
    {
        $exception = new static($safeMessage, $code, $previous);
        $exception->setSafeMessage($safeMessage, $messageData);

        return $exception;
    }
802749
protected function buildErrorResponse($error, $code = null)
    {
        if ($code !== null && (!is_int($code) || $code < 400)) {
            $code = null;
        }
        if (is_object($error)) {
            if ($error instanceof AccessDeniedException) {
                $error = $error->getMessage();
                if ($code === null) {
                    $code = Response::HTTP_UNAUTHORIZED;
                }
            } elseif ($error instanceof UserMessageException) {
                if ($error->getCode() >= 400) {
                    $code = $error->getCode();
                }
                $error = $error->getMessage();
            } elseif ($error instanceof Exception || $error instanceof Throwable) {
                $error = t('An unexpected error occurred');
            } elseif (is_callable([$error, '__toString'])) {
                $error = (string) $error;
            } else {
                $error = get_class($error);
            }
        }
        if ($code === null) {
            $code = Response::HTTP_INTERNAL_SERVER_ERROR;
        }

        return $this->getResponseFactory()->create(
            $error,
            $code,
            [
                'Content-Type' => 'text/plain; charset=UTF-8',
            ]
        );
    }
862505
public static function create($errorMessageFile = '')
    {
        if (!isset(self::$instances[$errorMessageFile])) {
            self::$instances[$errorMessageFile] = new self($errorMessageFile);
        }
        return self::$instances[$errorMessageFile];
    }
600680
protected function triggerError ($errorMessage)
	{
		$this->hasError 	= true;
		$this->errorMessage	= $errorMessage;
		
		throw new Exception ($errorMessage);
	}
646160
public static function getUploadErrorMessage(int $errorCode): string
    {
        switch ($errorCode) {
            case \UPLOAD_ERR_INI_SIZE:
                return 'The uploaded file exceeds the upload_max_filesize directive in php.ini';
            case \UPLOAD_ERR_FORM_SIZE:
                return 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form';
            case \UPLOAD_ERR_PARTIAL:
                return 'The uploaded file was only partially uploaded';
            case \UPLOAD_ERR_NO_FILE:
                return 'No file was uploaded';
            case \UPLOAD_ERR_NO_TMP_DIR:
                return 'Missing a temporary folder';
            case \UPLOAD_ERR_CANT_WRITE:
                return 'Failed to write file to disk';
            case \UPLOAD_ERR_EXTENSION:
                return 'File upload stopped by extension';
            default:
                return 'Unknown upload error';
        }
    }
403185
public static function createStartErrorReply(
        ContextInterface $context,
        int $errorCode,
        string $messageTemplate,
        array $messageParams
    ): array {
        $value = null;

        return [
            static::createErrorInfoEntry(
                $context->getCurrentBlockId(),
                $value,
                $errorCode,
                $messageTemplate,
                $messageParams
            ),
        ];
    }
218760
public static function getMessage($errorCode, $language = 'en')
    {
        self::initMessages();

        $messagesByLanguage = self::getMessagesByLanguage($language);
        if (!array_key_exists($errorCode, $messagesByLanguage)) {
            return $errorCode;
        }

        return $messagesByLanguage[$errorCode];
    }
269426
public function error( $message, $code = null, $data = null )
    {
        if ( null === $code && isset( $this->errorCodes[$message] ) )
        {
            $code = $this->errorCodes[$message];
        }

        return $this->getResponse( 'error', (object) array(
            'code'      => $code,
            'message'   => $message,
            'data'      => $data,
        ) );
    }
25113
protected function throwNewInvalidArgumentException ($errorMsg) {
		$msgs = [];
		if ($this->field) 
			$msgs[] = 'Field name: `'.$this->field->GetName() . '`, Field type: `'.get_class($this->field).'`';
		if ($this->form) 
			$msgs[] = 'Form id: `'.$this->form->GetId() . '`, Form type: `'.get_class($this->form).'`';
		$selfClass = version_compare(PHP_VERSION, '5.5', '>') ? self::class : __CLASS__;
		throw new \InvalidArgumentException(
			'['.$selfClass.'] ' . $errorMsg . ($msgs ? ' '.implode(', ', $msgs) : '')
		);
	}
52888
protected function Crash($errmsg = "Unknown Error", $code = 0, $exception = null)
	{
		$ex = $exception ? $exception : new Exception($errmsg, $code);
		throw $ex;
	}
1188416
public static function getErrorDescription($errorCode)
    {
        switch (intval($errorCode)) {
            default:
            case self::ERROR:
                return 'Undefined error.';
            case self::SYSTEM_ERROR:
                return 'A general system error occurred.';
            case self::MAINTENANCE_ERROR:
                return 'System is undergoing maintenance, request could not be handled.';
            case self::AUTHENTICATION_ERROR:
                return 'Login failed. Check your API credentials.';
            case self::CONFIGURATION_ERROR:
                return 'Config error occurred, e.g. terminal not configured properly. Check terminal settings.';
            case self::COMMUNICATION_ERROR:
                return 'Communication with issuer failed, please contact support.';
            case self::CONNECTION_ERROR:
                return 'Connection to issuer could not be established, please contact support.';
            case self::ACCOUNT_ERROR:
                return 'Issuer account data invalid, please contact support.';
            case self::TIMEOUT_ERROR:
                return 'Issuer does not respond within given time-frame - please reconcile.';
            case self::RESPONSE_ERROR:
                return 'Issuer returned invalid response - please reconcile and contact support.';
            case self::PARSING_ERROR:
                return 'Issuer response could not be parsed - please reconcile and contact support.';
            case self::INPUT_DATA_ERROR:
                return 'Invalid were data sent to the API.';
            case self::INVALID_TRANSACTION_TYPE_ERROR:
                return 'Invalid transaction type was passed to API.';
            case self::INPUT_DATA_MISSING_ERROR:
                return 'Required argument is missing.';
            case self::INPUT_DATA_FORMAT_ERROR:
                return 'Argument passed in invalid format.';
            case self::MASTERCARD_FORMAT_ERROR:
                return 'This is a format error stopped by MasterCard due to invalid formatting in certain fields.';
            case self::INPUT_DATA_INVALID_ERROR:
                return 'Argument passed in valid format but makes no sense (e.g. incorrect country code or currency).';
            case self::INVALID_XML_ERROR:
                return 'The input Builder could not be parsed due to invalid code.';
            case self::INVALID_CONTENT_TYPE_ERROR:
                return 'Missing or invalid content type: should be text/xml!';
            case self::WORKFLOW_ERROR:
                return 'A transaction was triggered that is not possible at this time in the workflow,' .
                       'e.g. a refund on a declined transaction.';
            case self::REFERENCE_NOT_FOUND_ERROR:
                return 'Reference transaction was not found.';
            case self::REFERENCE_WORKFLOW_ERROR:
                return 'Wrong Workflow specified.';
            case self::REFERENCE_INVALIDATED_ERROR:
                return 'Reference transaction already invalidated!';
            case self::REFERENCE_MISMATCH_ERROR:
                return 'Data mismatch with reference, e.g. amount exceeds reference.';
            case self::DOUBLE_TRANSACTION_ERROR:
                return 'Transaction doublet was detected, transaction was blocked.';
            case self::TRANSACTION_NOT_FOUND_ERROR:
                return 'The referenced transaction could not be found.';
            case self::CHARGEBACK_NOT_FOUND_ERROR:
                return 'Chargeback not found!';
            case self::RETRIEVAL_REQUEST_NOT_FOUND_ERROR:
                return 'Retrieval Request not found!';
            case self::FRAUD_REPORT_NOT_FOUND_ERROR:
                return 'Fraud Report not found!';
            case self::PROCESSING_ERROR:
                return 'Transaction declined by issuer.';
            case self::INVALID_CARD_ERROR:
                return 'Transaction declined, Credit card number is invalid.';
            case self::ISSUER_OCT_NOT_ENABLED_ERROR:
                return 'OCT not enabled error.';
            case self::EXPIRED_CARD_ERROR:
                return 'Transaction declined, expiration date not in the future or date invalid.';
            case self::TRANSACTION_PENDING_ERROR:
                return 'Transaction pending.';
            case self::CREDIT_EXCEEDED_ERROR:
                return 'Amount exceeds credit card limit.';
            case self::ISSUING_ERROR:
                return 'The voucher could not be issued!';
            case self::RISK_ERROR:
                return 'Transaction declined by risk management.';
            case self::INTERCHANGE_REJECT_ERROR:
                return 'Interchange reject received for transaction!';
            case self::FRONT_END_REJECT_ERROR:
                return 'Transaction declined by frontend reject!';
            case self::BIN_COUNTRY_CHECK_ERROR:
                return 'Card bin does not match billing country.';
            case self::CARD_BLACKLIST_ERROR:
                return 'Card is blacklisted.';
            case self::BIN_BLACKLIST_ERROR:
                return 'BIN blacklisted.';
            case self::COUNTRY_BLACKLIST_ERROR:
                return 'Country blacklisted.';
            case self::IP_BLACKLIST_ERROR:
                return 'IP address blacklisted.';
            case self::BLACKLIST_ERROR:
                return 'Value from the Transaction Request or Risk Parameters is blacklisted.';
            case self::CARD_WHITELIST_ERROR:
                return 'PAN Whitelist Filter blocked the transaction.';
            case self::CARD_LIMIT_EXCEEDED_ERROR:
                return 'Card limit exceeded configured limits.';
            case self::TERMINAL_LIMIT_EXCEEDED_ERROR:
                return 'Terminal limits exceeded.';
            case self::CONTRACT_LIMIT_EXCEEDED_ERROR:
                return 'MID limits exceeded.';
            case self::CARD_VELOCITY_EXCEEDED_ERROR:
                return 'Velocity by unknown card exceeded!';
            case self::CARD_TICKET_SIZE_EXCEEDED_ERROR:
                return 'Ticket size by unknown card exceeded!';
            case self::USER_LIMIT_EXCEEDED_ERROR:
                return 'User limit exceeded configured limits.';
            case self::MULTIPLE_FAILURE_DETECTION_ERROR:
                return 'Found user transaction declined by issuer.';
            case self::CS_DETECTION_ERROR:
                return 'CrossSelling Error!';
            case self::RECURRING_LIMIT_EXCEEDED_ERROR:
                return 'Amount/count by recurring subscription exceeded.';
            case self::IRIS_FILTER_DECLINED_ERROR:
                return 'Transaction declined by risk management.';
            case self::IRIS_FILTER_ON_HOLD_ERROR:
                return 'Transaction on hold, a manual review will be done';
            case self::AVS_ERROR:
                return 'Address Verification failed.';
            case self::MAX_MIND_RISK_ERROR:
                return 'MaxMind High Risk Error.';
            case self::THREAT_METRIX_RISK_ERROR:
                return 'ThreatMetrix High Risk Error.';
            case self::IP_NOT_WHITELISTED_ERROR:
                return 'Transaction declined by risk management, IP is NOT whitelisted!';
            case self::DOMAIN_BLACKLISTED_ERROR:
                return 'Transaction declined by risk management, domain is blacklisted!';
            case self::FRAUD_ERROR:
                return 'Please contact the risk team!';
            case self::IBAN_BLACKLIST_ERROR:
                return 'Transaction declined by risk management, iban blacklisted!';
            case self::REMOTE_ERROR:
                return 'Some error occurred on the issuer.';
            case self::REMOTE_SYSTEM_ERROR:
                return 'Some error occurred on the issuer.';
            case self::REMOTE_CONFIGURATION_ERROR:
                return 'Issuer configuration error.';
            case self::REMOTE_DATA_ERROR:
                return 'Some passed data caused an error on the issuer.';
            case self::REMOTE_WORKFLOW_ERROR:
                return 'Remote workflow error.';
            case self::REMOTE_TIMEOUT_ERROR:
                return 'Issuer has time-out with clearing network.';
            case self::REMOTE_CONNECTION_ERROR:
                return 'Issuer could not reach clearing network.';
        }
    }
708073
public static function errorToException($code){
    if(!isset(self::$codeMap[$code])){
      return new BadResponseException(sprintf(
        'Undefined error code "%s"',
        $code
      ));
    }
    $exceptionClass = self::$codeMap[$code];
    return  new $exceptionClass;
  }
1184309
public static function getErrorName($errorCode)
    {
        if (!isset(static::$errorNames[$errorCode])) {
            throw new InvalidArgumentException(sprintf('The error code "%s" does not exist for constraint of type "%s".', $errorCode, \get_called_class()));
        }

        return static::$errorNames[$errorCode];
    }
105352
public function dieInError($message, $errorCode = self::STATE_ERROR){
        $this->object_retour->strErreur = $message;
        $this->object_retour->statut = $errorCode;
        die();
    }
390488
public function showError($code, $description = '$'){
        $description = $description == "$" && isset($this->errorMsg[$code]) ? $this->errorMsg[$code] : $description;
        $description .= '['.$code.']';
        throw new Exception($description, 400);
    }