From 9eef31fbd85aa95cf0f94cc724bd7c14c8339129 Mon Sep 17 00:00:00 2001 From: Arno Kaimbacher Date: Mon, 28 Nov 2022 11:19:41 +0100 Subject: [PATCH] - throw badVerb for oai.controller if no or bad verb is defined --- src/controllers/oai.controller.ts | 19 ++++++++++++------- src/exceptions/OaiErrorCodes.ts | 2 +- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/controllers/oai.controller.ts b/src/controllers/oai.controller.ts index 673d295..471c729 100644 --- a/src/controllers/oai.controller.ts +++ b/src/controllers/oai.controller.ts @@ -187,13 +187,18 @@ export class OaiController { this.handleIllegalVerb(); } } else { - // try { - // console.log("Async code example.") - const err = new PageNotFoundException("verb not found"); - throw err; - // } catch (error) { // manually catching - // next(error); // passing to default middleware error handler - // } + // // try { + // // console.log("Async code example.") + // const err = new PageNotFoundException("verb not found"); + // throw err; + // // } catch (error) { // manually catching + // // next(error); // passing to default middleware error handler + // // } + throw new OaiModelException( + StatusCodes.INTERNAL_SERVER_ERROR, + "The verb provided in the request is illegal.", + OaiErrorCodes.BADVERB, + ); } } diff --git a/src/exceptions/OaiErrorCodes.ts b/src/exceptions/OaiErrorCodes.ts index 3cb2fd4..8361dcd 100644 --- a/src/exceptions/OaiErrorCodes.ts +++ b/src/exceptions/OaiErrorCodes.ts @@ -12,7 +12,7 @@ export enum OaiErrorCodes { // https://medium.com/@juliapassynkova/map-your-typescript-enums-e402d406b229 export const OaiModelError = new Map([ - [OaiErrorCodes.BADARGUMENT, 'badVerb'], + [OaiErrorCodes.BADVERB, 'badVerb'], [OaiErrorCodes.BADARGUMENT, 'badArgument'], [OaiErrorCodes.NORECORDSMATCH, 'noRecordsMatch'], [OaiErrorCodes.CANNOTDISSEMINATEFORMAT, 'cannotDisseminateFormat'],