Skip to content

Commit c554985

Browse files
committed
updated larkin error handling to return empty array for any invalid enum data type parameters
1 parent 6c62307 commit c554985

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

v2/definitions/econs.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,16 @@ module.exports = function (req, res, next, cb) {
5656
console.log("The error still returned from larkin")
5757
if (cb) {
5858
cb(error);
59-
} else if (error == "{\"success\":{\"v\":2,\"license\":\"CC-BY 4.0\",\"data\":[]}}") {
60-
console.log("THIS IS A SUCCESS JSON EVEN THOUGH IT'S CALLED ERROR", error)
61-
error = JSON.parse(error);
62-
res.status(200).json(error);
63-
} else {
64-
larkin.error(req, res, next, error);
6559
}
66-
return
60+
else {
61+
return larkin.error(req, res, next, error);
62+
}
6763
}
6864

6965
if (cb) {
7066
cb(null, data.rows);
7167
} else {
68+
7269
larkin.sendData(
7370
req,
7471
res,

v2/larkin.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,7 @@ const { Client, Pool } = require("pg");
143143
if (err) {
144144
larkin.log("error", err);
145145
if (err.message.includes(errorMessage)) {
146-
const enumError = JSON.stringify({"success": {"v": 2,"license": "CC-BY 4.0", "data": []}});
147-
callback(enumError);
146+
callback(null, {rows: []});
148147
}
149148
else {
150149
callback(err);

0 commit comments

Comments
 (0)