Skip to content
This repository was archived by the owner on Sep 17, 2023. It is now read-only.

Commit d35b57c

Browse files
committed
Rename InvalidContextKeyError to ContextKeyError
1 parent 1cad456 commit d35b57c

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

src/invalid-context-key-error.ts renamed to src/context-key-error.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ContextKey } from './context-key';
33
/**
44
* An error indicating the absence of context value with the given key.
55
*/
6-
export class InvalidContextKeyError extends Error {
6+
export class ContextKeyError extends Error {
77

88
/**
99
* A missing value key.

src/context-registry.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { AIterable } from 'a-iterable';
22
import { ContextRegistry } from './context-registry';
33
import { ContextValues } from './context-values';
4-
import { InvalidContextKeyError } from './invalid-context-key-error';
4+
import { ContextKeyError } from './context-key-error';
55
import { MultiContextKey, SingleContextKey } from './simple-context-key';
66
import Mock = jest.Mock;
77

@@ -60,8 +60,8 @@ describe('ContextRegistry', () => {
6060
expect(values.get(key)).toBe(value);
6161
});
6262
it('throws if there is neither default nor fallback value', () => {
63-
expect(() => values.get(new SingleContextKey(key.name))).toThrowError(InvalidContextKeyError);
64-
expect(() => values.get(new SingleContextKey(key.name), {})).toThrowError(InvalidContextKeyError);
63+
expect(() => values.get(new SingleContextKey(key.name))).toThrowError(ContextKeyError);
64+
expect(() => values.get(new SingleContextKey(key.name), {})).toThrowError(ContextKeyError);
6565
});
6666
it('provides fallback value is there is no provider', () => {
6767
expect(values.get(new SingleContextKey<string>(key.name), { or: 'fallback' })).toBe('fallback');

src/context-registry.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { ContextRef, ContextRequest } from './context-ref';
77
import { ContextSeeder, ContextSeeds } from './context-seeder';
88
import { contextValueSpec, ContextValueSpec } from './context-value-spec';
99
import { ContextValues } from './context-values';
10-
import { InvalidContextKeyError } from './invalid-context-key-error';
10+
import { ContextKeyError } from './context-key-error';
1111

1212
type SeedFactory<Ctx extends ContextValues, Seed> = (this: void, context: Ctx) => Seed;
1313

@@ -183,7 +183,7 @@ export class ContextRegistry<Ctx extends ContextValues = ContextValues> {
183183
const defaultValue = defaultProvider();
184184

185185
if (defaultValue == null) {
186-
throw new InvalidContextKeyError(key);
186+
throw new ContextKeyError(key);
187187
}
188188

189189
return defaultValue;

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
export * from './context-key';
2+
export * from './context-key-error';
23
export * from './context-ref';
34
export * from './context-registry';
45
export * from './context-seeder';
56
export * from './context-value-spec';
67
export * from './context-values';
7-
export * from './invalid-context-key-error';
88
export * from './simple-context-key';

0 commit comments

Comments
 (0)