From 2d89350ed56333b883482c674d8f9c47e8db3fab Mon Sep 17 00:00:00 2001 From: Ruben Verborgh Date: Mon, 26 Apr 2021 15:08:39 +0100 Subject: [PATCH] fix: Improve identifier error messages. --- src/util/identifiers/BaseIdentifierStrategy.ts | 4 ++-- test/unit/util/identifiers/BaseIdentifierStrategy.test.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/util/identifiers/BaseIdentifierStrategy.ts b/src/util/identifiers/BaseIdentifierStrategy.ts index d87e989f5..529a7fae4 100644 --- a/src/util/identifiers/BaseIdentifierStrategy.ts +++ b/src/util/identifiers/BaseIdentifierStrategy.ts @@ -13,10 +13,10 @@ export abstract class BaseIdentifierStrategy implements IdentifierStrategy { public getParentContainer(identifier: ResourceIdentifier): ResourceIdentifier { if (!this.supportsIdentifier(identifier)) { - throw new InternalServerError(`${identifier.path} is not supported`); + throw new InternalServerError(`The identifier ${identifier.path} is outside the configured identifier space.`); } if (this.isRootContainer(identifier)) { - throw new InternalServerError(`${identifier.path} is a root container and has no parent`); + throw new InternalServerError(`Cannot obtain the parent of ${identifier.path} because it is a root container.`); } // Trailing slash is necessary for URL library diff --git a/test/unit/util/identifiers/BaseIdentifierStrategy.test.ts b/test/unit/util/identifiers/BaseIdentifierStrategy.test.ts index 5e03c8905..5686bf39d 100644 --- a/test/unit/util/identifiers/BaseIdentifierStrategy.test.ts +++ b/test/unit/util/identifiers/BaseIdentifierStrategy.test.ts @@ -21,11 +21,11 @@ describe('A BaseIdentifierStrategy', (): void => { it('errors when attempting to get the parent of an unsupported identifier.', async(): Promise => { expect((): any => strategy.getParentContainer({ path: '/unsupported' })) - .toThrow('/unsupported is not supported'); + .toThrow('The identifier /unsupported is outside the configured identifier space.'); }); it('errors when attempting to get the parent of a root container.', async(): Promise => { expect((): any => strategy.getParentContainer({ path: 'http://test.com/root' })) - .toThrow('http://test.com/root is a root container and has no parent'); + .toThrow('Cannot obtain the parent of http://test.com/root because it is a root container.'); }); });