Skip to content

Commit 8e28999

Browse files
committed
Instructions for using error-code-tool
1 parent 26cdf17 commit 8e28999

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

packages/firestore/src/util/assert.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,27 @@ import { logError } from './log';
2626
* Returns `never` and can be used in expressions:
2727
* @example
2828
* let futureVar = fail('not implemented yet');
29+
*
30+
* @param code generate a new unique value with `yarn error-code:generate`
31+
* Search for an existing value using `yarn error-code:find X`
2932
*/
3033
export function fail(
3134
code: number,
3235
message: string,
3336
context?: Record<string, unknown>
3437
): never;
3538

39+
/**
40+
* Unconditionally fails, throwing an Error with the given message.
41+
* Messages are stripped in production builds.
42+
*
43+
* Returns `never` and can be used in expressions:
44+
* @example
45+
* let futureVar = fail('not implemented yet');
46+
*
47+
* @param code generate a new unique value with `yarn error-code:generate`
48+
* Search for an existing value using `yarn error-code:find X`
49+
*/
3650
export function fail(code: number, context?: Record<string, unknown>): never;
3751

3852
export function fail(
@@ -80,6 +94,9 @@ function _fail(
8094
* given message if it did.
8195
*
8296
* Messages are stripped in production builds.
97+
*
98+
* @param code generate a new unique value with `yarn error-code:generate`.
99+
* Search for an existing value using `yarn error-code:find X`
83100
*/
84101
export function hardAssert(
85102
assertion: boolean,
@@ -88,6 +105,15 @@ export function hardAssert(
88105
context?: Record<string, unknown>
89106
): asserts assertion;
90107

108+
/**
109+
* Fails if the given assertion condition is false, throwing an Error with the
110+
* given message if it did.
111+
*
112+
* Messages are stripped in production builds.
113+
*
114+
* @param code generate a new unique value with `yarn error-code:generate`.
115+
* Search for an existing value using `yarn error-code:find X`
116+
*/
91117
export function hardAssert(
92118
assertion: boolean,
93119
code: number,

0 commit comments

Comments
 (0)