Skip to content

Commit

Permalink
Fix incorrect error code on invalid @type value
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed May 29, 2020
1 parent f4ef0bc commit 151e463
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/Util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ export class Util {
} else if (valueType) { // Validate @type
if (typeof valueType !== 'string') {
throw new ErrorCoded(`The value of an '@type' must be a string, got '${JSON.stringify(valueType)}'`,
ERROR_CODES.INVALID_TYPE_VALUE);
ERROR_CODES.INVALID_TYPED_VALUE);
}
const typeTerm = this.createVocabOrBaseTerm(context, valueType);
if (!typeTerm) {
Expand Down
3 changes: 2 additions & 1 deletion test/Util-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,8 @@ describe('Util', () => {

it('with a @value and boolean @type should throw an error', async () => {
return expect(util.valueToTerm(context, 'key', { '@value': 'abc', '@type': true }, 0, []))
.rejects.toThrow(new Error('The value of an \'@type\' must be a string, got \'true\''));
.rejects.toThrow(new ErrorCoded('The value of an \'@type\' must be a string, got \'true\'',
ERROR_CODES.INVALID_TYPED_VALUE));
});

it('with a @value and invalid string @type should throw an error', async () => {
Expand Down

0 comments on commit 151e463

Please sign in to comment.