mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-11 00:08:30 +01:00
fix: correct error for missing context field (#3647)
When adding a strategy using a context field that did not exist, we threw an unknown error. This changes to throw NotFoundError so that our users can better know what they did wrong.
This commit is contained in:
parent
a984de7941
commit
f1db90d38c
@ -6,6 +6,7 @@ import {
|
||||
IContextFieldStore,
|
||||
ILegalValue,
|
||||
} from '../types/stores/context-field-store';
|
||||
import NotFoundError from '../error/notfound-error';
|
||||
|
||||
const COLUMNS = [
|
||||
'name',
|
||||
@ -76,11 +77,16 @@ class ContextFieldStore implements IContextFieldStore {
|
||||
}
|
||||
|
||||
async get(key: string): Promise<IContextField> {
|
||||
return this.db
|
||||
const row = await this.db
|
||||
.first(COLUMNS)
|
||||
.from(TABLE)
|
||||
.where({ name: key })
|
||||
.then(mapRow);
|
||||
.where({ name: key });
|
||||
if (!row) {
|
||||
throw new NotFoundError(
|
||||
`Could not find Context field with name ${key}`,
|
||||
);
|
||||
}
|
||||
return mapRow(row);
|
||||
}
|
||||
|
||||
async deleteAll(): Promise<void> {
|
||||
|
Loading…
Reference in New Issue
Block a user