Monday, 5 August 2019

How are custom error messages passed from node or is it handled in the frontend?

I have had this doubt for a while because there could be a lot of errors that could arise and I have never seen obscured error messages thrown from the sites I have been using. So for example I try to save the same data again that's supposed to be unique and I get such a error message from catch call on db save, E11000 duplicate key error collection: node-starter.communities index: name_1 dup key: { : \"react\" } . I can't just show this on the frontend, so should I save this and then checkcatch (err) { if(err.message = 'above error in full length'){ res.json({error: 'custom error message'); } else{ res.json({ error: err.message }); } } If more such errors require custom errors on the frontend, should I manually check and add such custom messages for such errors?

Submitted August 05, 2019 at 09:27AM by sum__sleples

No comments:

Post a Comment