Skip to content

Commit

Permalink
core-plugin-api: added ErrorApi* prefix to Error and ErrorContext types
Browse files Browse the repository at this point in the history
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
  • Loading branch information
Rugvip committed Nov 15, 2021
1 parent 880ad8c commit b6a4bac
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 19 deletions.
5 changes: 5 additions & 0 deletions .changeset/yellow-deers-act.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@backstage/core-plugin-api': patch
---

Deprecated the `Error` and `ErrorContext` types, replacing them with identical `ErrorApiError` and `ErrorApiErrorContext` types.
7 changes: 4 additions & 3 deletions packages/core-app-api/api-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ import { bitbucketAuthApiRef } from '@backstage/core-plugin-api';
import { ComponentType } from 'react';
import { ConfigReader } from '@backstage/config';
import { DiscoveryApi } from '@backstage/core-plugin-api';
import { Error as Error_2 } from '@backstage/core-plugin-api';
import { ErrorApi } from '@backstage/core-plugin-api';
import { ErrorApiError } from '@backstage/core-plugin-api';
import { ErrorApiErrorContext } from '@backstage/core-plugin-api';
import { ErrorContext } from '@backstage/core-plugin-api';
import { ExternalRouteRef } from '@backstage/core-plugin-api';
import { FeatureFlag } from '@backstage/core-plugin-api';
Expand Down Expand Up @@ -327,8 +328,8 @@ export class ErrorAlerter implements ErrorApi {
constructor(alertApi: AlertApi, errorApi: ErrorApi);
// (undocumented)
error$(): Observable<{
error: Error_2;
context?: ErrorContext | undefined;
error: ErrorApiError;
context?: ErrorApiErrorContext | undefined;
}>;
// (undocumented)
post(error: Error, context?: ErrorContext): void;
Expand Down
30 changes: 18 additions & 12 deletions packages/core-plugin-api/api-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -404,21 +404,29 @@ export interface ElementCollection {
}): ElementCollection;
}

// @public @deprecated (undocumented)
type Error_2 = ErrorApiError;
export { Error_2 as Error };

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

// @public
type Error_2 = {
export type ErrorApiError = {
name: string;
message: string;
stack?: string;
};
export { Error_2 as Error };

// @public
export type ErrorApi = {
post(error: Error_2, context?: ErrorContext): void;
error$(): Observable_2<{
error: Error_2;
context?: ErrorContext;
}>;
export type ErrorApiErrorContext = {
hidden?: boolean;
};

// @public
Expand All @@ -431,10 +439,8 @@ export type ErrorBoundaryFallbackProps = {
resetError: () => void;
};

// @public
export type ErrorContext = {
hidden?: boolean;
};
// @public @deprecated (undocumented)
export type ErrorContext = ErrorApiErrorContext;

// @public
export type Extension<T> = {
Expand Down
23 changes: 19 additions & 4 deletions packages/core-plugin-api/src/apis/definitions/ErrorApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,34 @@ import { Observable } from '@backstage/types';
*
* @public
*/
export type Error = {
export type ErrorApiError = {
name: string;
message: string;
stack?: string;
};

/**
* @public
* @deprecated Use ErrorApiError instead
*/
export type Error = ErrorApiError;

/**
* Provides additional information about an error that was posted to the application.
*
* @public
*/
export type ErrorContext = {
export type ErrorApiErrorContext = {
// If set to true, this error should not be displayed to the user. Defaults to false.
hidden?: boolean;
};

/**
* @public
* @deprecated Use ErrorApiErrorContext instead
*/
export type ErrorContext = ErrorApiErrorContext;

/**
* The error API is used to report errors to the app, and display them to the user.
*
Expand All @@ -62,12 +74,15 @@ export type ErrorApi = {
/**
* Post an error for handling by the application.
*/
post(error: Error, context?: ErrorContext): void;
post(error: ErrorApiError, context?: ErrorApiErrorContext): void;

/**
* Observe errors posted by other parts of the application.
*/
error$(): Observable<{ error: Error; context?: ErrorContext }>;
error$(): Observable<{
error: ErrorApiError;
context?: ErrorApiErrorContext;
}>;
};

/**
Expand Down

0 comments on commit b6a4bac

Please sign in to comment.