#How to return error in Flow?

10 messages · Page 1 of 1 (latest)

lament mortar
#

How to return error with some message if some conditions are not met?

primal quail
#

Try retuning error.message or error.stack instead of just error.

lament mortar
#

This is my end point script if someone should get error via api

module.exports = async function(data) {
return error.message('ERROR')
}

primal quail
#

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.

lament mortar
lament mortar
#

is it possible to customize this?

lament mortar
#

Ping

primal quail
#

Pong