Sign up (with export icon)

core/errorreporter

Api-module iconmodule

Interfaces

Type Definitions

Functions

  • Chevron-right icon

    onEditorError( callback ) → () => void

    Registers a callback for errors that escape an editor, and returns a function that unregisters it.

    const off = onEditorError( ( { error, source } ) => {
    	if ( source !== myEditor ) {
    		return;
    	}
    
    	reportToMyErrorTracker( error );
    } );
    Copy code

    There is one registration surface for the whole page rather than one per editor, so an integrator running several editors compares source with their own instance, as above. Registering the same callback twice gives two independent registrations, and each unregisters on its own.

    One error can reach the callback more than once, once for every editor it is attributed to — see source.

    Reporting only. Nothing is restarted and nothing is swallowed — the error still reaches the console.

    Parameters

    callback: EditorErrorCallback

    Returns

    () => void