WordPress at a glance
function is not described

WP_Fatal_Error_Handler::detect_error() protected WP 5.2.0

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

{} It's a method of the class: WP_Fatal_Error_Handler{}

No Hooks.

Return

Array|null. Error that was triggered, or null if no error received or if 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.

Code of WP_Fatal_Error_Handler::detect_error() WP 5.7.2

<?php
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;
}