fix: Rename UnsupportedHttpError into BadRequestError.

This commit is contained in:
Ruben Verborgh
2020-11-27 10:25:05 +01:00
committed by Joachim Van Herwegen
parent 03ffaaed43
commit af8f1976cd
53 changed files with 177 additions and 171 deletions

View File

@@ -3,7 +3,7 @@ import type { RepresentationPreferences } from '../../../../src/ldp/representati
import type { ResourceIdentifier } from '../../../../src/ldp/representation/ResourceIdentifier';
import type { RepresentationConverter } from '../../../../src/storage/conversion/RepresentationConverter';
import { PreferenceSupport } from '../../../../src/storage/routing/PreferenceSupport';
import { UnsupportedHttpError } from '../../../../src/util/errors/UnsupportedHttpError';
import { BadRequestHttpError } from '../../../../src/util/errors/BadRequestHttpError';
describe('A PreferenceSupport', (): void => {
const type = 'internal/quads';
@@ -26,7 +26,7 @@ describe('A PreferenceSupport', (): void => {
it('returns false if the converter does not support the input.', async(): Promise<void> => {
converter.canHandle = jest.fn((): any => {
throw new UnsupportedHttpError();
throw new BadRequestHttpError();
});
await expect(support.supports({ identifier, representation })).resolves.toBe(false);
expect(converter.canHandle).toHaveBeenCalledTimes(1);

View File

@@ -1,6 +1,6 @@
import type { ResourceStore } from '../../../../src/storage/ResourceStore';
import { RegexRouterRule } from '../../../../src/storage/routing/RegexRouterRule';
import { UnsupportedHttpError } from '../../../../src/util/errors/UnsupportedHttpError';
import { BadRequestHttpError } from '../../../../src/util/errors/BadRequestHttpError';
describe('A RegexRouterRule', (): void => {
const base = 'http://test.com/';
@@ -9,13 +9,13 @@ describe('A RegexRouterRule', (): void => {
it('rejects identifiers not containing the base.', async(): Promise<void> => {
const router = new RegexRouterRule(base, {});
await expect(router.canHandle({ identifier: { path: 'http://notTest.com/apple' }}))
.rejects.toThrow(new UnsupportedHttpError(`Identifiers need to start with http://test.com`));
.rejects.toThrow(new BadRequestHttpError(`Identifiers need to start with http://test.com`));
});
it('rejects identifiers not matching any regex.', async(): Promise<void> => {
const router = new RegexRouterRule(base, { pear: store });
await expect(router.canHandle({ identifier: { path: `${base}apple/` }}))
.rejects.toThrow(new UnsupportedHttpError(`No stored regexes match http://test.com/apple/`));
.rejects.toThrow(new BadRequestHttpError(`No stored regexes match http://test.com/apple/`));
});
it('accepts identifiers matching any regex.', async(): Promise<void> => {