Translates the plugin error codes to human readable error strings.

@param array $codes Associative list of scope and object as key and error code as value
@return array List of translated error messages
351709
protected function translatePluginErrorCodes( array $codes )
	{
		$errors = [];
		$i18n = $this->getContext()->getI18n();

		foreach( $codes as $scope => $list )
		{
			foreach( $list as $object => $errcode )
			{
				$key = $scope . ( !in_array( $scope, ['coupon', 'product'] ) ? '.' . $object : '' ) . '.' . $errcode;
				$errors[] = sprintf( $i18n->dt( 'mshop/code', $key ), $object );
			}
		}

		return $errors;
	}
431984
public function mapErrorsToLogType($code)
    {
        switch ($code) {
            case E_ERROR:
            case E_RECOVERABLE_ERROR:
            case E_CORE_ERROR:
            case E_COMPILE_ERROR:
            case E_USER_ERROR:
            case E_PARSE:
                return Logger::ERROR;
            case E_WARNING:
            case E_USER_WARNING:
            case E_CORE_WARNING:
            case E_COMPILE_WARNING:
                return Logger::WARNING;
            case E_NOTICE:
            case E_USER_NOTICE:
                return Logger::NOTICE;
            case E_STRICT:
            case E_DEPRECATED:
            case E_USER_DEPRECATED:
                return Logger::INFO;
        }

        return Logger::ERROR;
    }
902130
public function sendError($code = 204, $vars = null)
    {
        static $errors = [];

        if (empty($errors)) {
            $errors = require(str_replace('Cli', 'Config', __DIR__) . DIRECTORY_SEPARATOR . 'Errors.php');
        }

        if (isset($errors[ $code ])) {
            $languageKey = $errors[ $code ];
        }

        $languageKey = strtoupper($code . '_' . $languageKey);

        $error = [
            'code'    => $code,
            'title'   => language()->getLine($languageKey . '_TITLE'),
            'message' => language()->getLine($languageKey . '_MESSAGE'),
        ];

        $this->statusCode = $code;
        $this->reasonPhrase = $error[ 'title' ];

        if (is_string($vars)) {
            $error[ 'message' ] = $vars;
        } elseif (is_array($vars)) {
            $error = array_merge($error, $vars);
        }

        $this->write(
            (new Format())
                ->setContextualClass(Format::DANGER)
                ->setString($error[ 'code' ] . ' - ' . $error[ 'title' ])
                ->setNewLinesAfter(1)
        );

        $this->write(
            (new Format())
                ->setString($error[ 'message' ])
                ->setNewLinesAfter(1)
        );

        exit(EXIT_ERROR);
    }
890577
public function errorMessages()
    {
        $msgs = array();
        foreach ($this->errors as $key => $values) {
            foreach ($values as $value) {
                array_push($msgs, "$key $value");
            }
        }
        return $msgs;
    }
689753
public function getErrorType($code)
    {
        switch ($code) {
            case E_ERROR:
                return self::$stack['type'] = 'Error'; // 1
            case E_WARNING:
                return self::$stack['type'] = 'Warning'; // 2
            case E_PARSE:
                return self::$stack['type'] = 'Parse'; // 4
            case E_NOTICE:
                return self::$stack['type'] = 'Notice'; // 8
            case E_CORE_ERROR:
                return self::$stack['type'] = 'Core-Error'; // 16
            case E_CORE_WARNING:
                return self::$stack['type'] = 'Core Warning'; // 32
            case E_COMPILE_ERROR:
                return self::$stack['type'] = 'Compile Error'; // 64
            case E_COMPILE_WARNING:
                return self::$stack['type'] = 'Compile Warning'; // 128
            case E_USER_ERROR:
                return self::$stack['type'] = 'User Error'; // 256
            case E_USER_WARNING:
                return self::$stack['type'] = 'User Warning'; // 512
            case E_USER_NOTICE:
                return self::$stack['type'] = 'User Notice'; // 1024
            case E_STRICT:
                return self::$stack['type'] = 'Strict'; // 2048
            case E_RECOVERABLE_ERROR:
                return self::$stack['type'] = 'Recoverable Error'; // 4096
            case E_DEPRECATED:
                return self::$stack['type'] = 'Deprecated'; // 8192
            case E_USER_DEPRECATED:
                return self::$stack['type'] = 'User Deprecated'; // 16384
            default:
                return self::$stack['type'] = 'Error';
        }
    }
936780
public function resolveErrorHandler($errorCode)
    {
        return array_key_exists($errorCode, $this->errorHandlers)
            ? call_user_func_array($this->errorHandlers[$errorCode], [])
            : '';
    }
1080536
public static function getMessageFromCode($code)
    {
        if (!array_key_exists($code, self::$responseCodes)) {
            throw new \Exception('The header code '.$code.' is not valid.');
        }

        return self::$responseCodes[$code];
    }
112029
public function getErrorMessage($intCode, $arrOptions=array()) {
		if (isset($arrOptions['error']))
			return $arrOptions['error'];

		if (isset($arrOptions['message']))
			return $this->locale->insert($arrOptions['message'], array('value' => isset($arrOptions['value']) ? $arrOptions['value'] : $arrOptions['field'], 'field' => $arrOptions['field']));

		$field = isset($arrOptions['label']) ? $arrOptions['label'] : (isset($arrOptions['field']) ? $this->locale->get($arrOptions['field']) : '');

		switch ($intCode) {
			case FILTER_VALIDATE_REQUIRED:
				return $this->locale->insert('error.empty', array('value' => $field));
			case FILTER_VALIDATE_PASSWORD:
				return $this->locale->get('error.password');
			case FILTER_VALIDATE_USERNAME:
				return $this->locale->insert('error.username', array('value' => '"'.$arrOptions['value'].'"'));
			case FILTER_VALIDATE_IDENTIFIER:
				return $this->locale->insert('error.identifier', array('value' => '"'.$arrOptions['value'].'"'));
			case FILTER_VALIDATE_RESOURCE:
				return $this->locale->insert('error.resource', array('value' => '"'.$arrOptions['value'].'"'));
			case FILTER_VALIDATE_EMAIL:
				return $this->locale->insert('error.not_a_address', array('value' => '"'.$arrOptions['value'].'"', 'type' => 'E-mail'));
			case FILTER_VALIDATE_IPV4:
				return $this->locale->insert('error.not_a_address', array('value' => '"'.$arrOptions['value'].'"', 'type' => 'IPv4'));
			case FILTER_VALIDATE_IPV6:
				return $this->locale->insert('error.not_a_address', array('value' => '"'.$arrOptions['value'].'"', 'type' => 'IPv6'));
			case FILTER_VALIDATE_IP:
				return $this->locale->insert('error.not_a_address', array('value' => '"'.$arrOptions['value'].'"', 'type' => 'IP'));
			case FILTER_VALIDATE_URL:
				return $this->locale->insert('error.not_a_url', array('value' => $arrOptions['value']));
			case FILTER_VALIDATE_FLOAT:
				return $this->locale->insert('error.not_a_number', array('value' => $field));
			case FILTER_VALIDATE_INT:
				if (isset($arrOptions['min_range']) && isset($arrOptions['max_range']))
					return $this->locale->insert('error.in_between', array('value' => $field, 'min' => $arrOptions['min_range'], 'max' => $arrOptions['max_range']));
				elseif (isset($arrOptions['min_range']))
					return $this->locale->insert('error.greater_than', array('value' => $field, 'count' => $arrOptions['min_range']));
				elseif (isset($arrOptions['max_range']))
					return $this->locale->insert('error.less_than', array('value' => $field, 'count' => $arrOptions['max_range']));
				else
					return $this->locale->insert('error.not_a_int', array('value' => $field));
			case FILTER_VALIDATE_BOOLEAN:
				break;
			case FILTER_VALIDATE_MIN_LENGTH:
				return $this->locale->insert('error.too_short', array('value' => $field, 'count' => $arrOptions['len']));
			case FILTER_VALIDATE_MAX_LENGTH:
				return $this->locale->insert('error.too_long', array('value' => $field, 'count' => $arrOptions['len']));
			case FILTER_VALIDATE_LENGTH:
				return $this->locale->insert('error.wrong_range', array('value' => $field, 'min' => $arrOptions['min'], 'max' => $arrOptions['max']));
			case FILTER_VALIDATE_DATE_RANGE:
				$arrOptions['format'] = isset($arrOptions['format']) ? $arrOptions['format'] : $this->locale->getDateFormat('date.format.default');
				return $this->locale->insert('error.date_range', array('value' => $field, 'min' => date($arrOptions['format'], $arrOptions['min']), 'max' => date($arrOptions['format'], $arrOptions['max'])));
			case FILTER_VALIDATE_DATE_START_END:
				$arrOptions['format'] = isset($arrOptions['format']) ? $arrOptions['format'] : $this->locale->getDateFormat('date.format.default');
				return $this->locale->insert('error.date_start_end', array('value' => $field, 'end' => date($arrOptions['format'], $arrOptions['end'])));
			default:
				// too_long
				// too_short
				// empty (Muss ausgefüllt werden)
				// invalid
				// start_before_end
				// range: Ist keine gültige {model}
				break;
		}

		return $this->locale->insert('error.invalid', array('value' => isset($arrOptions['value']) ? $arrOptions['value'] : $field, 'field' => $field));
	}
257919
protected function _toData($errors)
    {
        $data = array();

        foreach ($errors as $error) {
            if ($error instanceof Exception) {
                $data[] = array('code' => $error->getCode(),'message' => $error->getMessage());
            } elseif ($error instanceof AnError) {
                $data[] = $error->toArray();
            }
        }

        return $data;
    }
979231
private function codeToMessage($code) {
        // get the error message belong to the given code
        switch ($code) {
            case \Th\FileDownloader::FILE_WRONG_MIME:
                $message = "File is of the wrong MIME type";
                break;
            case \Th\FileDownloader::FILE_WRONG_EXTENSION:
                $message = "File is of the wrong extension";
                break;
            case \Th\FileDownloader::INVALID_DOWNLOAD_DIR:
                $message = "User set download directory does not exist";
                break;
            default:
                $message = "Unknown download error";
                break;
        }

        // done, return the error message
        return $message;
    }
869926
public function errors(array $messages): string
    {
        if (!$messages) {
            return ''; // No error messages.
        }
        $messages      = $this->c::markdown($messages, ['no_p' => true]);
        return $markup = '<ul><li>'.implode('</li><li>', $messages).'</li></ul>';
    }
1007491
public function translateToAnyLanguageOf(array $languageCodes): self
    {
        foreach ($languageCodes as $languageCode) {
            if (!is_string($languageCode) || empty($languageCode)) {
                throw new InvalidArgumentException('$languageCodes', 'All language codes should be non-empty strings');
            }
        }

        $this->targetVersionProperties['allLanguageCodesList'] = $languageCodes;

        return $this;
    }
637280
function translate ($code)
    {
        if (preg_match_all("/<\?_\(\"(.*)\"\)\?>/siU", $code, $matches, PREG_SET_ORDER)) {
            foreach ($matches as $match) {
                if (isset($match[1])) {
                    $code = str_replace($match[0], gettext(stripslashes($match[1])), $code);
                }
            }
        }
        return $code;
    }
11243
protected function codeStr($codes)
    {
        // If we get something that is already a code string, just pass it back
        if (!is_array($codes) && strpos($codes, ';')) {
            return $codes;
        }

        $codes = Helper::toArray($codes);

        // Sort for the sake of consistency and testability
        sort($codes);

        return implode(';', $codes);
    }
1051531
public function getErrors(): array
    {
        $errors = $this->validate()->getErrors();
        foreach ($errors as &$error) {
            if (is_string($error) && Translator::isMessage($error)) {
                // translate error message
                $error = $this->say($error);
            }

            unset($error);
        }

        return $errors;
    }
377674
public function getMessageByCode(& $code, array $data = null)
    {
        // If we do not use a reference, then that defeats the purpose of
        // making the $errorMap a static property.
        $map = &static::getErrorMap();

        // When you can't find the code, use a default one.
        if (!\array_key_exists($code, $map)) {
            $code = static::UNKNOWN;
        }

        if (\is_array($data) && count($data) > 0) {
            return \vsprintf($map[$code], $data);
        }

        return $map[$code];
    }
1065715
public static function translateErrorCode($error_code)
    {
        $constants = get_defined_constants(true);
        if (array_key_exists('Core', $constants)) {
            foreach ($constants['Core'] as $constant => $value) {
                if (substr($constant, 0, 2) == 'E_' && $value == $error_code) {
                    return $constant;
                }
            }
        }
        return "E_UNKNOWN";
    }