WP_Fatal_Error_Handler::detect_error()protectedWP 5.2.0

Detects the error causing the crash if it should be handled.

Method of the class: WP_Fatal_Error_Handler{}

No Hooks.

Return

Array|null. Error information returned by error_get_last(), or null if none was recorded or the error should not be handled.

Usage

// protected - for code of main (parent) or child class
$result = $this->detect_error();

Changelog

Since 5.2.0 Introduced.

WP_Fatal_Error_Handler::detect_error() code WP 6.5.2

protected function detect_error() {
	$error = error_get_last();

	// No error, just skip the error handling code.
	if ( null === $error ) {
		return null;
	}

	// Bail if this error should not be handled.
	if ( ! $this->should_handle_error( $error ) ) {
		return null;
	}

	return $error;
}