Node.js Expressを使用してHTTP REST APIを作成しています。 私は、次のよう約束を返し下線サービス呼び出す方法があります:Node.js Express、エラー処理はconsole.errorでのみ動作します
function getAllApps(request, response) {
appService.getAllApps(request.query.$expand).then(function (apps) {
response.status(200).send(apps);
})
}
を、私は以下のような方法をマップ:
var api = express.app;
api.get('/apps', getAllApps);
を今、私はエラーとして取り扱いを導入しています以下:
function getAllApps(request, response) {
appService.getApps(request.query.$expand).then(function (apps) {
response.status(200).send(apps);
})
.catch(function (err) {
console.error('Error occurred in Apps Api: ' + err);
response.status(400).send(err);
});
}
期待通りに機能しているexcepエラーが発生したとき、私は次のようにコンソールで完全なエラー・スタックを得ることをトン:
Express is listening on 127.0.0.1:3000
Web Api ready
Error occurred in Apps Api: Error: Actions is not defined on the model.
しかし、私のHTTPメソッドの戻り値400を、ボディが空である、それだけで中括弧が含まれています
{}
あなたは実際に投げますか、あるいは「アプリ」は空ですか? – Bergi
'.stack'は、エラーafaikの列挙できないプロパティです。つまり、' send'によって無視されます。とにかく、それをユーザーに送信したくないのですか? – Bergi
@Bergi done、apologize – Raffaeu