@@ -21,30 +21,34 @@ import { logError } from './log';
21
21
22
22
/**
23
23
* Unconditionally fails, throwing a developer facing INTERNAL_ERROR
24
- *
24
+ *
25
25
* @param appName App name for tagging the error
26
26
* @throws FirebaseError
27
27
*/
28
- export function fail (
29
- appName : string
30
- ) : never {
28
+ export function fail ( appName : string ) : never {
31
29
throw AUTH_ERROR_FACTORY . create ( AuthErrorCode . INTERNAL_ERROR , { appName } ) ;
32
30
}
33
31
34
32
/**
35
33
* Verifies the given condition and fails if false, throwing a developer facing error
36
- *
34
+ *
37
35
* @param assertion
38
- * @param appName
36
+ * @param appName
39
37
*/
40
38
export function assert ( assertion : boolean , appName : string ) : asserts assertion {
41
39
if ( ! assertion ) {
42
40
fail ( appName ) ;
43
41
}
44
42
}
45
43
46
- export function assertStringOrUndefined ( assertion : unknown , appName : string ) : asserts assertion is string | undefined {
47
- assert ( typeof assertion === 'string' || typeof assertion === 'undefined' , appName ) ;
44
+ export function assertStringOrUndefined (
45
+ assertion : unknown ,
46
+ appName : string
47
+ ) : asserts assertion is string | undefined {
48
+ assert (
49
+ typeof assertion === 'string' || typeof assertion === 'undefined' ,
50
+ appName
51
+ ) ;
48
52
}
49
53
50
54
/**
@@ -56,8 +60,7 @@ export function assertStringOrUndefined(assertion: unknown, appName: string): as
56
60
export function debugFail ( failure : string ) : never {
57
61
// Log the failure in addition to throw an exception, just in case the
58
62
// exception is swallowed.
59
- const message =
60
- `AUTH (${ SDK_VERSION } ) INTERNAL ASSERTION FAILED: ` + failure ;
63
+ const message = `AUTH (${ SDK_VERSION } ) INTERNAL ASSERTION FAILED: ` + failure ;
61
64
logError ( message ) ;
62
65
63
66
// NOTE: We don't use FirestoreError here because these are internal failures
@@ -69,12 +72,15 @@ export function debugFail(failure: string): never {
69
72
/**
70
73
* Fails if the given assertion condition is false, throwing an Error with the
71
74
* given message if it did.
72
- *
75
+ *
73
76
* @param assertion
74
77
* @param message
75
78
*/
76
- export function debugAssert ( assertion : boolean , message : string ) : asserts assertion {
79
+ export function debugAssert (
80
+ assertion : boolean ,
81
+ message : string
82
+ ) : asserts assertion {
77
83
if ( ! assertion ) {
78
84
debugFail ( message ) ;
79
85
}
80
- }
86
+ }
0 commit comments