Skip to content

Commit fd6c9fb

Browse files
committed
fix: add Provider Not Ready Error
1 parent a14669f commit fd6c9fb

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

packages/server/test/errors.spec.ts

+9
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
GeneralError,
55
InvalidContextError,
66
ParseError,
7+
ProviderNotReadyError,
78
TargetingKeyMissingError,
89
TypeMismatchError,
910
} from '../src';
@@ -56,4 +57,12 @@ describe('Errors', () => {
5657
expect(error.name).toBe('InvalidContextError');
5758
expect(error instanceof InvalidContextError).toBe(true);
5859
});
60+
61+
it('ProviderNotReadyError', () => {
62+
const error = new ProviderNotReadyError('message');
63+
expect(error.message).toBe('message');
64+
expect(error.code).toBe(ErrorCode.PROVIDER_NOT_READY);
65+
expect(error.name).toBe('ProviderNotReadyError');
66+
expect(error instanceof ProviderNotReadyError).toBe(true);
67+
});
5968
});

packages/shared/src/errors/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ export * from './type-mismatch-error';
55
export * from './targeting-key-missing-error';
66
export * from './invalid-context-error';
77
export * from './open-feature-error-abstract';
8+
export * from './provider-not-ready-error';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { OpenFeatureError } from './open-feature-error-abstract';
2+
import { ErrorCode } from '../evaluation';
3+
4+
export class ProviderNotReadyError extends OpenFeatureError {
5+
code: ErrorCode;
6+
constructor(message?: string) {
7+
super(message);
8+
Object.setPrototypeOf(this, ProviderNotReadyError.prototype);
9+
this.name = 'ProviderNotReadyError';
10+
this.code = ErrorCode.PROVIDER_NOT_READY;
11+
}
12+
}

0 commit comments

Comments
 (0)