UNPKG

1.62 kBTypeScriptView Raw
1declare abstract class StorybookError extends Error {
2 /**
3 * Category of the error. Used to classify the type of error, e.g., 'PREVIEW_API'.
4 */
5 abstract readonly category: string;
6 /**
7 * Code representing the error. Used to uniquely identify the error, e.g., 1.
8 */
9 abstract readonly code: number;
10 /**
11 * A properly written error message template for this error.
12 * @see https://github.com/storybookjs/storybook/blob/next/code/lib/core-events/src/errors/README.md#how-to-write-a-proper-error-message
13 */
14 abstract template(): string;
15 /**
16 * Data associated with the error. Used to provide additional information in the error message or to be passed to telemetry.
17 */
18 readonly data: {};
19 /**
20 * Specifies the documentation for the error.
21 * - If `true`, links to a documentation page on the Storybook website (make sure it exists before enabling).
22 * - If a string, uses the provided URL for documentation (external or FAQ links).
23 * - If `false` (default), no documentation link is added.
24 */
25 documentation: boolean | string | string[];
26 /**
27 * Flag used to easily determine if the error originates from Storybook.
28 */
29 readonly fromStorybook: true;
30 get fullErrorCode(): `SB_${this["category"]}_${string}`;
31 /**
32 * Overrides the default `Error.name` property in the format: SB_<CATEGORY>_<CODE>.
33 */
34 get name(): string;
35 /**
36 * Generates the error message along with additional documentation link (if applicable).
37 */
38 get message(): string;
39}
40
41export { StorybookError as S };