1

i'm doing this:

context.fail({
            message: "Invalid Token!",
            code: app.error["010"].code,
        });

and when i call api from postman, it is returning me:

{ 
  "errorMessage": "[object Object]"
}

even i'm not sending any key named errorMessage

My question is, am i using correct way to return error if yes, why it is behaving like this if no, what is the correct way to handling error in serverless

I'll be thankful.

4

1 回答 1

0

返回一个错误对象,它应该可以工作。还使用回调而不是上下文来返回错误(这是现在的默认行为,context.fail 仅适用于旧版支持)

callback(new Error('Your message'))

于 2016-12-06T12:55:34.123 回答