Skip to content

Commit

Permalink
fix: add Provider Not Ready Error (#680)
Browse files Browse the repository at this point in the history
<!-- Please use this template for your pull request. -->
<!-- Please use the sections that you need and delete other sections -->

## This PR
Adds an Error class for the error code Provider Not Ready. To match the
other error codes.

Signed-off-by: Todd Baert <[email protected]>
  • Loading branch information
Billlynch authored Nov 22, 2023
1 parent a14669f commit b0054f9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/server/test/errors.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
GeneralError,
InvalidContextError,
ParseError,
ProviderNotReadyError,
TargetingKeyMissingError,
TypeMismatchError,
} from '../src';
Expand Down Expand Up @@ -56,4 +57,12 @@ describe('Errors', () => {
expect(error.name).toBe('InvalidContextError');
expect(error instanceof InvalidContextError).toBe(true);
});

it('ProviderNotReadyError', () => {
const error = new ProviderNotReadyError('message');
expect(error.message).toBe('message');
expect(error.code).toBe(ErrorCode.PROVIDER_NOT_READY);
expect(error.name).toBe('ProviderNotReadyError');
expect(error instanceof ProviderNotReadyError).toBe(true);
});
});
1 change: 1 addition & 0 deletions packages/shared/src/errors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ export * from './type-mismatch-error';
export * from './targeting-key-missing-error';
export * from './invalid-context-error';
export * from './open-feature-error-abstract';
export * from './provider-not-ready-error';
12 changes: 12 additions & 0 deletions packages/shared/src/errors/provider-not-ready-error.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { OpenFeatureError } from './open-feature-error-abstract';
import { ErrorCode } from '../evaluation';

export class ProviderNotReadyError extends OpenFeatureError {
code: ErrorCode;
constructor(message?: string) {
super(message);
Object.setPrototypeOf(this, ProviderNotReadyError.prototype);
this.name = 'ProviderNotReadyError';
this.code = ErrorCode.PROVIDER_NOT_READY;
}
}

0 comments on commit b0054f9

Please sign in to comment.