|
|
@@ -41,6 +41,12 @@ module.exports = {
|
|
|
return res.json(orders);
|
|
|
})
|
|
|
.catch((err)=>{
|
|
|
+ if(typeof(err) === "string"){
|
|
|
+ return res.json(err);
|
|
|
+ }
|
|
|
+ if(err.name === "ValidationError"){
|
|
|
+ return res.json(err.errors.name.properties.message);
|
|
|
+ }
|
|
|
return res.json("ERROR: UNABLE TO RETRIEVE YOUR ORDERS");
|
|
|
});
|
|
|
},
|
|
|
@@ -87,6 +93,12 @@ module.exports = {
|
|
|
return res.json(orders);
|
|
|
})
|
|
|
.catch((err)=>{
|
|
|
+ if(typeof(err) === "string"){
|
|
|
+ return res.json(err);
|
|
|
+ }
|
|
|
+ if(err.name === "ValidationError"){
|
|
|
+ return res.json(err.errors.name.properties.message);
|
|
|
+ }
|
|
|
return res.json("ERROR: UNABLE TO RETRIEVE YOUR TRANSACTIONS");
|
|
|
});
|
|
|
},
|
|
|
@@ -121,6 +133,12 @@ module.exports = {
|
|
|
res.json(response);
|
|
|
})
|
|
|
.catch((err)=>{
|
|
|
+ if(typeof(err) === "string"){
|
|
|
+ return res.json(err);
|
|
|
+ }
|
|
|
+ if(err.name === "ValidationError"){
|
|
|
+ return res.json(err.errors.name.properties.message);
|
|
|
+ }
|
|
|
return res.json("ERROR: UNABLE TO SAVE ORDER");
|
|
|
});
|
|
|
|
|
|
@@ -178,6 +196,12 @@ module.exports = {
|
|
|
return merchant.save();
|
|
|
})
|
|
|
.catch((err)=>{
|
|
|
+ if(typeof(err) === "string"){
|
|
|
+ return res.json(err);
|
|
|
+ }
|
|
|
+ if(err.name === "ValidationError"){
|
|
|
+ return res.json(err.errors.name.properties.message);
|
|
|
+ }
|
|
|
return res.json("ERROR: UNABLE TO REMOVE ORDER");
|
|
|
});
|
|
|
}
|