change: Do not warn in canHandle.

This commit is contained in:
Ruben Verborgh 2020-11-29 10:53:43 +01:00
parent 10946ffdb1
commit baf68889f9
4 changed files with 0 additions and 7 deletions

View File

@ -21,7 +21,6 @@ export class BasicResponseWriter extends ResponseWriter {
public async canHandle(input: { response: HttpResponse; result: ResponseDescription | Error }): Promise<void> { public async canHandle(input: { response: HttpResponse; result: ResponseDescription | Error }): Promise<void> {
if (input.result instanceof Error || input.result.metadata?.contentType === INTERNAL_QUADS) { if (input.result instanceof Error || input.result.metadata?.contentType === INTERNAL_QUADS) {
this.logger.warn('This writer only supports binary ResponseDescriptions');
throw new NotImplementedHttpError('Only successful binary responses are supported'); throw new NotImplementedHttpError('Only successful binary responses are supported');
} }
} }

View File

@ -13,7 +13,6 @@ export class ErrorResponseWriter extends ResponseWriter {
public async canHandle(input: { response: HttpResponse; result: ResponseDescription | Error }): Promise<void> { public async canHandle(input: { response: HttpResponse; result: ResponseDescription | Error }): Promise<void> {
if (!(input.result instanceof Error)) { if (!(input.result instanceof Error)) {
this.logger.warn('This writer can only write errors');
throw new NotImplementedHttpError('Only errors are supported'); throw new NotImplementedHttpError('Only errors are supported');
} }
} }

View File

@ -20,7 +20,6 @@ export class SparqlUpdateBodyParser extends BodyParser {
public async canHandle({ request }: BodyParserArgs): Promise<void> { public async canHandle({ request }: BodyParserArgs): Promise<void> {
const contentType = request.headers['content-type']; const contentType = request.headers['content-type'];
if (contentType !== APPLICATION_SPARQL_UPDATE) { if (contentType !== APPLICATION_SPARQL_UPDATE) {
this.logger.debug(`Unsupported content type: ${contentType}`);
throw new UnsupportedMediaTypeHttpError('This parser only supports SPARQL UPDATE data.'); throw new UnsupportedMediaTypeHttpError('This parser only supports SPARQL UPDATE data.');
} }
} }

View File

@ -1,4 +1,3 @@
import { getLoggerFor } from '../../logging/LogUtil';
import { NotImplementedHttpError } from '../../util/errors/NotImplementedHttpError'; import { NotImplementedHttpError } from '../../util/errors/NotImplementedHttpError';
import type { Operation } from '../operations/Operation'; import type { Operation } from '../operations/Operation';
import type { PermissionSet } from './PermissionSet'; import type { PermissionSet } from './PermissionSet';
@ -13,11 +12,8 @@ const SUPPORTED_METHODS = new Set([ ...READ_METHODS, ...WRITE_METHODS ]);
* Specifically: GET, HEAD, POST, PUT and DELETE. * Specifically: GET, HEAD, POST, PUT and DELETE.
*/ */
export class MethodPermissionsExtractor extends PermissionsExtractor { export class MethodPermissionsExtractor extends PermissionsExtractor {
protected readonly logger = getLoggerFor(this);
public async canHandle({ method }: Operation): Promise<void> { public async canHandle({ method }: Operation): Promise<void> {
if (!SUPPORTED_METHODS.has(method)) { if (!SUPPORTED_METHODS.has(method)) {
this.logger.warn(`Unrecognized method ${method}`);
throw new NotImplementedHttpError(`Cannot determine permissions of ${method}`); throw new NotImplementedHttpError(`Cannot determine permissions of ${method}`);
} }
} }