1

我正在使用節點中的new--inspect參數來調試我的應用程序Chrome Developer Tools。我在承諾鏈的末尾有一個非常基本的catch,但返回的錯誤沒有清楚地顯示它們來自哪裏。節點catch()錯誤沒有顯示錯誤發生的文件

我能看到哪個文件錯誤發源於?

leagues(app).getLeagues(passData) 
    .then(teamsApi.getNorsemenTeams) 
     .then(filterBarGamesIndex) 
    .then(gamesApi.getNorseGames) 
    .then(gamesApi.getFilteredTeams) 
    .then(function (passData) { 
     res.render('games', { 
     title: 'Results', 
     passData: passData, 
     type: req.originalUrl.split('/')[2] 
     }) 
    }) 
     .catch(function(err) { 
      console.error(err); //Line 35 
     }); 
} 

​​

,並直接從控制檯的錯誤是:

TypeError: Cannot read property 'Intermediate_Division_2' of undefined 
    at /var/www/beta.norsemanfc.co.uk/app/controllers/filterBar/fixturesIndex.js:27:62 
    at Array.filter (native) 
    at module.exports (/var/www/beta.norsemanfc.co.uk/app/controllers/filterBar/fixturesIndex.js:25:42) 
    at process._tickCallback (internal/process/next_tick.js:103:7) 
+1

根據錯誤,它出現錯誤發生在'filterBarGamesIndex' –

+0

我同意,但是我的系統中不存在這樣的文件:/ –

+0

您使用的瀏覽器是什麼?如果您使用的是Firefox,您可以在[Mozilla頁面]上試用'console.log(err.lineNumber)'(https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Error )。 – brennanenanen

回答

3

您可能要拋售有關異常的詳細信息,如

的console.log(ERR。堆棧);

+0

這會導致非常類似的錯誤令人遺憾'TypeError:無法讀取屬性'Intermediate_Division_2'undefined at /var/www/beta.norsemanfc.co.uk/app/controllers/filterBar/fixturesIndex.js:27:62 at Array .filter(native) at module.exports(/var/www/beta.norsemanfc.co.uk/app/controllers/filterBar/fixturesIndex.js:25:42) at process._tickCallback(internal/process/next_tick。 js:103:7)' –

+0

由於'filterBar/fix turesIndex.js'根本不是真正的文件。我相信這可能與我使用'jade'作爲我的模板有關? –

+0

這不是「非常相似」。你在那裏有更多的地點。 –