1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Add better messages for 404 errors on admin api

This commit is contained in:
Nick O'Leary 2020-06-02 22:52:22 +01:00
parent 8995fa9ed1
commit f0193b0f67
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9

View File

@ -62,7 +62,7 @@ var api = module.exports = {
return resolve(result);
} else {
runtime.log.audit({event: "nodes.info.get",id:id,error:"not_found"}, opts.req);
var err = new Error();
var err = new Error("Node not found");
err.code = "not_found";
err.status = 404;
return reject(err);
@ -105,7 +105,7 @@ var api = module.exports = {
return resolve(result);
} else {
runtime.log.audit({event: "nodes.config.get",id:id,error:"not_found"}, opts.req);
var err = new Error();
var err = new Error("Node not found");
err.code = "not_found";
err.status = 404;
return reject(err);
@ -145,7 +145,7 @@ var api = module.exports = {
return resolve(result);
} else {
runtime.log.audit({event: "nodes.module.get",id:opts.module,error:"not_found"}, opts.req);
var err = new Error();
var err = new Error("Module not found");
err.code = "not_found";
err.status = 404;
return reject(err);
@ -232,7 +232,7 @@ var api = module.exports = {
var module = runtime.nodes.getModuleInfo(opts.module);
if (!module) {
runtime.log.audit({event: "nodes.remove",module:opts.module,error:"not_found"}, opts.req);
var err = new Error();
var err = new Error("Module not found");
err.code = "not_found";
err.status = 404;
return reject(err);
@ -278,7 +278,7 @@ var api = module.exports = {
var module = runtime.nodes.getModuleInfo(mod);
if (!module) {
runtime.log.audit({event: "nodes.module.set",module:mod,error:"not_found"}, opts.req);
var err = new Error();
var err = new Error("Module not found");
err.code = "not_found";
err.status = 404;
return reject(err);
@ -329,7 +329,7 @@ var api = module.exports = {
var node = runtime.nodes.getNodeInfo(id);
if (!node) {
runtime.log.audit({event: "nodes.info.set",id:id,error:"not_found"}, opts.req);
var err = new Error();
var err = new Error("Node not found");
err.code = "not_found";
err.status = 404;
return reject(err);