mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
fix: Improve identifier error messages.
This commit is contained in:
parent
1d9b027a57
commit
2d89350ed5
@ -13,10 +13,10 @@ export abstract class BaseIdentifierStrategy implements IdentifierStrategy {
|
|||||||
|
|
||||||
public getParentContainer(identifier: ResourceIdentifier): ResourceIdentifier {
|
public getParentContainer(identifier: ResourceIdentifier): ResourceIdentifier {
|
||||||
if (!this.supportsIdentifier(identifier)) {
|
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)) {
|
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
|
// Trailing slash is necessary for URL library
|
||||||
|
@ -21,11 +21,11 @@ describe('A BaseIdentifierStrategy', (): void => {
|
|||||||
|
|
||||||
it('errors when attempting to get the parent of an unsupported identifier.', async(): Promise<void> => {
|
it('errors when attempting to get the parent of an unsupported identifier.', async(): Promise<void> => {
|
||||||
expect((): any => strategy.getParentContainer({ path: '/unsupported' }))
|
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<void> => {
|
it('errors when attempting to get the parent of a root container.', async(): Promise<void> => {
|
||||||
expect((): any => strategy.getParentContainer({ path: 'http://test.com/root' }))
|
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.');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user