I'm studying the differences between return Promise.reject , and, throw new Error, looks similar , here the catch code:
} catch (err) {
return Promise.reject(err);
//throw new Error(err);
}
for throw new Error I see only is added 'TypeError'
sometimes i use, inside async function, and looks works all fine too..
throw(err);
{
"data": {
"userlogs": null
},
"errors": [
{
"message": "TypeError: Cannot read property 'findAll' of undefined",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"userlogs"
]
}
]
}
with Promise the message is cleaner:
{
"data": {
"userlogs": null
},
"errors": [
{
"message": "Cannot read property 'findAll' of undefined",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"userlogs"
]
}
]
}
is there and advise about that? i'm using await for call the functions, it's better to use Promise.reject in that scenary, and throw new Error is used for any case?