#How to return error in Flow?
10 messages · Page 1 of 1 (latest)
Try retuning error.message or error.stack instead of just error.
I got this one
[1] [19:10:02.539] ERROR: error is not defined
[1] err: {
[1] "type": "ReferenceError",
[1] "message": "error is not defined",
[1] "stack":
[1] ReferenceError: error is not defined
[1] at module.exports (vm.js:2:2)
This is my end point script if someone should get error via api
module.exports = async function(data) {
return error.message('ERROR')
}
You have to put your code in a try-catch block for that to work like so:
module.exports = async function (data) {
try {
// Your code
} catch(error) {
return error.message
}
}
Oh, I think I read your question wrong, sorry.
You can just throw an error in your code to make it fail. throw new Error('My Message'). There is currently a bug though that prevents you from seeing the error message.
At the moment there is no working solution where the api user can get a personal error other than
{
"errors": [
{
"message": "An unexpected error occurred.",
"extensions": {
"code": "INTERNAL_SERVER_ERROR"
}
}
]
}
?
is it possible to customize this?
Ping
Pong