如何捕获匿名函数内部引发的错误

时间:2019-11-13 22:59:46

标签: javascript error-handling anonymous-function

我如何从主上下文访问data.Count值或从主上下文捕获匿名函数中引发的错误?

await model.scan().where('email').equals(someEmail).exec((err, data) => {
                //throw an error
                if (data.Count > 0) 
                    throw new Error("error message");
                // or just return value
                return data.Count;
            });     

0 个答案:

没有答案