Update the error handling data for ldb API responses.

Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
Fred Boniface 2023-09-20 13:53:21 +01:00
parent ee0439fcb1
commit 68f92c41b8
2 changed files with 10 additions and 4 deletions

View File

@ -1,6 +1,6 @@
// statusCodes should be a map, not an object
const statusCodes = {
export const statusCodes = {
400: "data not found",
700: "no authentication attempt",
701: "invalid credentials",
@ -14,5 +14,10 @@ const statusCodes = {
951: "unknown server error",
};
export const msgCodes = new Map <string, string>([
["LOC_NOT_FOUND", "Location not found. If you are sure that the location exists, there may be a fault with the data provider."],
["AUTH_ERR", "Authentication Error"],
])
module.exports = statusCodes;
export { statusCodes };
//export { statusCodes };

View File

@ -7,6 +7,7 @@ const san = require("../utils/sanitizer.utils");
const db = require("../services/dbAccess.services");
import { transform as staffStationTransform } from "../utils/translators/ldb/staffStation";
import { msgCodes } from "../configs/errorCodes.configs";
const ldbKey = process.env.OWL_LDB_KEY;
const ldbsvKey = process.env.OWL_LDB_SVKEY;
@ -29,8 +30,8 @@ async function get(id, staff = false) {
} catch (err) {
log.out(`ldbService.get: Error, Unable to find CRS: ${err}`, "info");
return {
ERROR: "NOT_FOUND",
description: "The entered station was not found.",
obStatus: "LOC_NOT_FOUND",
obMsg: msgCodes.get(this.obStatus),
};
}
}