ドメインを使用することは未処理の例外を処理する適切な方法であると読みましたが、このエラーをエンド ユーザーに通知する方法がわかりません。このエラーがエンド ユーザーに気付かれないようにするために、エラー メッセージを表示したいと考えています。
私の現在のコードは次のようなものです:
var domain = require('domain').create();
domain.on('error', function(err) {
console.error('Unhandled exception occured:\n', err.stack.toString());
// Don't know how to access the response (nor request) object here so I can return error
// res.json({error:'Error ocurred'});
});
domain.run(function() {
// Here is complete logic including definition of http server
...
});