LLMS_Generator::get_error_code( int $code, obj $class )

Retrieve a human-readable error code from a machine-readable error number


Parameters Parameters

$code

(int) (Required) Error number.

$class

(obj) (Required) Generator class instance.


Top ↑

Return Return

(string) A human-readable error code.


Top ↑

Source Source

File: includes/class.llms.generator.php

	protected function get_error_code( $code, $class ) {

		// See if the error code is a native php exception code constant.
		$ret = llms_php_error_constant_to_code( $code );

		// Code is not a native PHP exception code.
		if ( is_numeric( $ret ) ) {

			$reflect   = new ReflectionClass( $class );
			$constants = array_flip( $reflect->getConstants() );
			$ret       = isset( $constants[ $code ] ) ? $constants[ $code ] : 'ERROR_UNKNOWN';

		}

		/**
		 * Filter the human-readable error retrieved from a given error code
		 *
		 * @since 4.9.0
		 *
		 * @param string $ret   The human-readable error code.
		 * @param int    $code  The initial error code as an integer.
		 * @param obj    $class Generator class instance.
		 */
		return apply_filters( 'llms_generator_get_error_code', $ret, $code, $class );

	}


Top ↑

Changelog Changelog

Changelog
Version Description
4.9.0 Handle PHP core errors, warnings, notices, etc... with a human-readable error code.
4.7.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.