Skip to main content

ErrorApi

Home > @backstage/core-plugin-api > ErrorApi

The error API is used to report errors to the app, and display them to the user.

Signature:

export type ErrorApi = {
post(error: ErrorApiError, context?: ErrorApiErrorContext): void;
error$(): Observable<{
error: ErrorApiError;
context?: ErrorApiErrorContext;
}>;
};

References: ErrorApiError, ErrorApiErrorContext, Observable

Remarks

Plugins can use this API as a method of displaying errors to the user, but also to report errors for collection by error reporting services.

If an error can be displayed inline, e.g. as feedback in a form, that should be preferred over relying on this API to display the error. The main use of this API for displaying errors should be for asynchronous errors, such as a failing background process.

Even if an error is displayed inline, it should still be reported through this API if it would be useful to collect or log it for debugging purposes, but with the hidden flag set. For example, an error arising from form field validation should probably not be reported, while a failed REST call would be useful to report.