Tag: 命中

我应该完全消除从我使用的代码(Bluebird)承诺的try / catch?

在我调用promisified函数之前,我有几个非常基本的设置步骤,我正在考虑将它们包装在try / catch块中,因为这似乎是最简单的方法。 不过,对我来说似乎有点肮脏。 我应该做一个返回一个Promise的函数,即使它很简单吗? 这是一个例子。 try thingyId = req.params.id # here I am 99.999% sure that params is defined, # but if for some bizarre reason it's not, I'd like to handle that error # instead of breaking the whole program catch console.log "error: " + e # do normal promisified functions 或者我应该写这个 setThingyId […]