get error message for given error code

@param int $code error code
@return string
@uses socket_strerror() to translate error code to error message
@uses get_defined_constants() to check for related error constant
341727
protected static function getErrorMessage($code)
    {
        $string = socket_strerror($code);

        // search constant starting with SOCKET_ for this error code
        foreach (get_defined_constants() as $key => $value) {
            if($value === $code && strpos($key, 'SOCKET_') === 0) {
                $string .= ' (' . $key . ')';
                break;
            }
        }

        return $string;
    }
1215679
public function getErrorMessage($error)
    {
        $jsonResponse = json_decode($error->getResponse()->getBody(), true);
        $errorMessage = $error->getMessage();

        if (count($jsonResponse['errors']) > 0) {
            $errorMessage = $jsonResponse['errors'][0]['message'];
        }

        return $errorMessage;
    }
808519
public static function getErrorMessage($code)
    {
        $app = Application::getFacadeApplication();
        $defaultStorage = $app->make(StorageLocationFactory::class)->fetchDefault()->getName();
        $msg = '';
        switch ($code) {
            case self::E_PHP_NO_FILE:
            case self::E_FILE_INVALID:
                $msg = t('Invalid file.');
                break;
            case self::E_FILE_INVALID_EXTENSION:
                $msg = t('Invalid file extension.');
                break;
            case self::E_PHP_FILE_PARTIAL_UPLOAD:
                $msg = t('The file was only partially uploaded.');
                break;
            case self::E_FILE_INVALID_STORAGE_LOCATION:
                $msg = t('No default file storage location could be found to store this file.');
                break;
            case self::E_FILE_EXCEEDS_POST_MAX_FILE_SIZE:
                $msg = t('Uploaded file is too large. The current value of post_max_filesize is %s',
                    ini_get('post_max_size'));
                break;
            case self::E_PHP_FILE_EXCEEDS_HTML_MAX_FILE_SIZE:
            case self::E_PHP_FILE_EXCEEDS_UPLOAD_MAX_FILESIZE:
                $msg = t('Uploaded file is too large. The current value of upload_max_filesize is %s',
                    ini_get('upload_max_filesize'));
                break;
            case self::E_FILE_UNABLE_TO_STORE:
                $msg = t('Unable to copy file to storage location "%s". Please check the settings for the storage location.',
                    $defaultStorage);
                break;
            case self::E_FILE_UNABLE_TO_STORE_PREFIX_PROVIDED:
                $msg = t('Unable to copy file to storage location "%s". This file already exists in your site, or there is insufficient disk space for this operation.', $defaultStorage);
                break;
            case self::E_PHP_NO_TMP_DIR:
                $msg = t('Missing a temporary folder.');
                break;
            case self::E_PHP_CANT_WRITE:
                $msg = t('Failed to write file to disk.');
                break;
            case self::E_PHP_CANT_WRITE:
                $msg = t('A PHP extension stopped the file upload.');
                break;
            case self::E_PHP_FILE_ERROR_DEFAULT:
            default:
                $msg = t("An unknown error occurred while uploading the file. Please check that file uploads are enabled, and that your file does not exceed the size of the post_max_size or upload_max_filesize variables.\n\nFile Uploads: %s\nMax Upload File Size: %s\nPost Max Size: %s",
                    ini_get('file_uploads'), ini_get('upload_max_filesize'), ini_get('post_max_size'));
                break;
        }

        return $msg;
    }
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;
    }
714151
public function getError( $_code ) {
		if ( isset( $this->errors[$_code] ) ) {
			return $this->errors[$_code];
		}
		else {
			return 'No such error code ' . $_code . '! Quit inventing errors!!!';
		}
	}
655224
public static function get($code)
  {
    if (array_key_exists($code, self::$translations)) {
      return self::$translations[$code];
    }
    return sprintf('[%s]', $code);
  }
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];
    }
1332640
final public static function get_header_string(int $code) {
		if (!isset(self::$header_string[$code]))
			$code = 404;
		return [
			'code' => $code,
			'msg'  => self::$header_string[$code],
		];
	}
1111221
public function getMessage(int $code): string
    {
        return $this->statusExists($code) ? $this->statuses[$code] : self::UNDEFINED_STATUS_MESSAGE;
    }
1271407
public static function __(string $code) : string
    {
        $t = self::getInstance();
        if (!isset($t->translations[$code])) {
            return $code;
        }
        return $t->translations[$code];
    }
661054
public function getLocaleByCode($code)
    {
        $locales = $this->getLocales();
        if (array_key_exists($code, $locales)) {
            return $locales[$code];
        }
    }
235356
public function check($code) {
        $code = trim($code);
        // last token should be ;
        if(substr($code, -1) != ';') {
            $this->error = ['line' => (substr_count($code, "\n") + 1), 'prev' => ']', 'token' => ';', 'must' => true];
            return false;
        }
        // exclude last token
        $code = substr($code, 0, -1);
        // get all tokens
        $tokens = token_get_all($code);
        $prev = false;
        $this->error['line'] = false;
        foreach($tokens as $token) {
            if(is_array($token)) {
                $tn = token_name($token['0']);
                if(in_array($tn, ['T_WHITESPACE', 'T_COMMENT']))
                    continue;
                $this->error = ['line' => $token[2], 'prev' => $prev, 'token' => $tn];
                if(!in_array($tn, self::$valid_tokens))
                    return false;
                elseif($tn == 'T_STRING' && !in_array(strtolower($token[1]), ['true', 'false']))
                    return false;
                if($this->validSequence($prev, $tn))
                   $prev = $tn;
                else
                    return false; 
            } else {
                // line will be defined in any case, so no needed to define it here 
                $this->error['prev'] = $prev;
                $this->error['token'] = $token;
                if(in_array($token, self::$valid_symbols) && $this->validSequence($prev, $token))
                    $prev = $token;
                else
                    return false;
            }
        }
        // chek pairs of $braces
        $braces = 0;
        $inString = 0;
        $this->error['line'] = 0;
        foreach($tokens as $token) {
            if($inString & 1) {
                switch ($token) {
                    case '`':
                    case '"': --$inString; break;
                }
            } else {
                switch ($token) {
                    case '`':
                    case '"': ++$inString; break;
     
                    case '[': case '(': ++$braces; break;
                    case ']': case ')':
                        if ($inString) {
                            --$inString;
                        }
                        else {
                            --$braces;
                            if ($braces < 0) {
                                return false;
                            }
                        }
                    break;
                }
            }
        }
        if ($braces) {
            return false;
        }
        return true;
    }
171304
public static function message($code)
    {
        if (array_key_exists($code, self::$messages)) {
            return self::$messages[$code];
        }

        return null;
    }
487995
private function parse($code)
    {
        try {
            return $this->parser->parse($code);
        } catch (\PhpParser\Error $e) {
            if (\strpos($e->getMessage(), 'unexpected EOF') === false) {
                throw $e;
            }

            // If we got an unexpected EOF, let's try it again with a semicolon.
            return $this->parser->parse($code . ';');
        }
    }
730991
public static function getPHPErrorSeverity($code) {
		$PHP_ERROR_LEVELS = [
			E_PARSE => \Psr\Log\LogLevel::ERROR,
			E_ERROR => \Psr\Log\LogLevel::ERROR,
			E_CORE_ERROR => \Psr\Log\LogLevel::ERROR,
			E_COMPILE_ERROR => \Psr\Log\LogLevel::ERROR,
			E_USER_ERROR => \Psr\Log\LogLevel::ERROR,
			E_RECOVERABLE_ERROR => \Psr\Log\LogLevel::ERROR,
			E_WARNING => \Psr\Log\LogLevel::WARNING,
			E_CORE_WARNING => \Psr\Log\LogLevel::WARNING,
			E_COMPILE_WARNING => \Psr\Log\LogLevel::WARNING,
			E_USER_WARNING => \Psr\Log\LogLevel::WARNING,
			E_NOTICE => \Psr\Log\LogLevel::NOTICE,
			E_USER_NOTICE => \Psr\Log\LogLevel::NOTICE,
			E_STRICT => \Psr\Log\LogLevel::NOTICE,
		];
		if(!isset($PHP_ERROR_LEVELS[$code]))
			return;
		return $PHP_ERROR_LEVELS[$code];
	}
170790
public function getMessageString($errorCode)
	{
		return isset($this->errorMessages[$errorCode]) ? $this->errorMessages[$errorCode] : null;
	}
287806
private function GetMessage($code)
	{
		$errors = array();
		$errors["-1"] = "Error in request Data was not by received intact by Skipjack Transaction Network.";
		$errors["0"] = "Communication Failure Error in Request and Response at IP level. Use Get Transaction Status before retrying transaction.";
		$errors["1"] = "Success";
		$errors["-35"] = "Credit card number does not comply with the Mod10 check. Retry with correct credit card number.";
		$errors["-37"] = "Skipjack is unable to communicate with payment Processor.  Please Retry.";
		$errors["-39"] = "Check HTML Serial Number length and that it is a correct/valid number. Confirm you are sending to the correct environment (Development or Production)";
		$errors["-51"] = "Length or value of zip code The value or length for billing zip code is incorrect.";
		$errors["-52"] = "The value or length for shipping zip code is incorrect.";
		$errors["-53"] = "The value or length for credit card expiration month is incorrect.";
		$errors["-54"] = "The value or length of the month or year of the credit card account number was incorrect.";
		$errors["-55"] = "The value or length or billing street address is incorrect.";
		$errors["-56"] = "The value or length of the shipping address is incorrect.";
		$errors["-57"] = "The length of the transaction amount must be at least 3 digits long (excluding the decimal place).";
		$errors["-58"] = "Merchant Name associated with Skipjack account is misconfigured or invalid";
		$errors["-59"] = "Merchant Address associated with Skipjack account is misconfigured or invalid Skipjack Financial Services Skipjack Integration GuidePage 52 of 251";
		$errors["-60"] = "Merchant State associated with Skipjack account is misconfigured or invalid";
		$errors["-61"] = "The value or length for shipping state/province is empty.";
		$errors["-62"] = "The value for length orderstring is empty.";
		$errors["-64"] = "The value for the phone number is incorrect.";
		$errors["-65"] = "Error empty sjname The value or length for billing name is empty.";
		$errors["-66"] = "The value or length for billing e-mail is empty.";
		$errors["-67"] = "The value or length for billing street address is empty.";
		$errors["-68"] = "The value or length for billing city is empty.";
		$errors["-69"] = "The value or length for billing state is empty.";
		$errors["-70"] = "Zip Code field is empty.";
		$errors["-71"] = "Ordernumber field is empty.";
		$errors["-72"] = "Account number field is empty";
		$errors["-73"] = "Month field is empty.";
		$errors["-74"] = "Year field is empty.";
		$errors["-75"] = "Serial number field is empty.";
		$errors["-76"] = "Transaction amount field is empty.";
		$errors["-77"] = "Orderstring field is empty.";
		$errors["-78"] = "Shiptophone field is empty.";
		$errors["-79"] = "Length or value sjname The value or length for billing name is empty.";
		$errors["-80"] = "Error in the length or value of shiptophone.";
		$errors["-81"] = "Length or value of Customer location";
		$errors["-82"] = "The value or length for billing state is empty.";
		$errors["-83"] = "The value or length for shipping phone is empty.";
		$errors["-84"] = "There is already an existing pending transaction in the register sharing the posted Order Number.";
		$errors["-85"] = "Airline leg field value is invalid or empty.";
		$errors["-86"] = "Airline ticket info field is invalid or empty";
		$errors["-87"] = "Point of Sale check routing number is invalid or empty.";
		$errors["-88"] = "Point of Sale check account number is invalid or empty.";
		$errors["-89"] = "Point of Sale check MICR invalid or empty.";
		$errors["-90"] = "Point of Sale check number missingor invalid Point of Sale check number invalid or empty.";
		$errors["-91"] = "\"Make CVV a required field feature\" enabled in the Merchant Account Setup interface but no CVV code was sent in the transaction data.";
		$errors["-92"] = "Approval Code Invalid. Approval Code is a 6 digit code.";
		$errors["-93"] = "Blind Credits Request Refused \"Allow Blind Credits\" option must be enabled on the Skipjack Merchant Account.";
		$errors["-94"] = "BlindCreditsFailed Skipjack Financial Services Skipjack Integration GuidePage 53 of 251";
		$errors["-95"] = "Voice Authorization Request Refused Voice Authorization option must be enabled on the Skipjack";
		$errors["-96"] = "Voice Authorizations Failed";
		$errors["-97"] = "Fraud Rejection Violates Velocity Settling.";
		$errors["-98"] = "Invalid Discount Amount";
		$errors["-99"] = "POS PIN Debit Pin BlockDebit-specific";
		$errors["-100"] = "POS PIN Debit Invalid Key Serial Number Debit-specific";
		$errors["-101"] = "Data for Verified by Visa/MC Secure Code is invalid.";
		$errors["-102"] = "Authentication Data Not Allowed";
		$errors["-103"] = "POS checkdateofbirth variable contains a birth date in an incorrect format. Use MM/DD/YYYY format for this variable.";
		$errors["-104"] = "POS checkidentificationtype variable contains a identificationtype value which is invalid. Use the single digit value where Social Security Number=1, Drivers License=2 for this variable.";
		$errors["-105"] = "Track Data is in invalid format.";
		$errors["-106"] = "POS Check Invalid Account Type";
		$errors["-107"] = "POS PIN Debit Invalid Sequence Number";
		$errors["-108"] = "Invalid Transaction ID";
		$errors["-109"] = "Invalid From Account Type";
		$errors["-110"] = "Pos Error Invalid To Account Type";
		$errors["-112"] = "Pos Error Invalid Auth Option";
		$errors["-113"] = "Pos Error Transaction Failed";
		$errors["-114"] = "Pos Error Invalid Incoming Eci";
		$errors["-115"] = "POS Check Invalid Check Type";
		$errors["-116"] = "POS Check lane or cash register number is invalid. Use a valid lane or cash register number that has been configured in the Skipjack Merchant Account.";
		$errors["-117"] = "POS Check Invalid Cashier Number";


		return (isset($errors[$code])) ? $errors[$code] : "Unknown Error";
	}