1

apiフォルダーからエラーをキャッチしたいと思います。azure-mobile-apps-nodeのエラーミドルウェア

はしかし、どのハンドラからトリガエラーがない限り明示エラー処理ミドルウェアキャッチは何もapp.get(someroute,handler)

この上の任意の提案をルーティング標準Expressを使用して宣言されていませんか?

ありがとうございます。

app.js

mobile.api.import('./api'); 
mobile.tables.initialize() 
    .then(function() { 
     app.use(mobile); // Register the Azure Mobile Apps middleware 
     app.listen(process.env.PORT || 3000); // Listen for requests 
    }) 
    .then(function(){ 
     if (process.env.NODE_ENV == 'production'){ 
      ///handle errors on prod 
      app.use(function(err, req, res, next) { 
       console.log('error catch - here'); 
       res.statusCode = 500; 
       res.end(); 
      }); 
     } 
    }); 

API/testing.js

module.exports = { 
    "get": function (req, res, next) { 
     throw new Error('this is error'); 
    } 
}; 

答えて

0

あなたの理解は正しいです。 Azure Mobile Apps用Node.js SDKはExpressを使用しているため、同じセマンティクスを使用しています。 (サイドノート - カスタムAPI機能を実装しないことについて簡単に説明しましたが、本当にAzureポータルのインポータル編集機能をサポートしています)。

プログラミングに関する質問に回答するこのフォーラムではなく、より良い質問です。何が起こりたいですか? https://github.com/Azure/azure-mobile-apps-nodeリポジトリに問題を提出して、その議論ができるようにしてください。

0

mobile.api.importの後にmobile.use(function (err, req, res, next) { /* ... */ })を追加してみてください。これにより、azure-mobile-appsエラーハンドラの前にエラー処理ミドルウェアがマウントされます。

関連する問題