我正在使用節點中的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)
根據錯誤,它出現錯誤發生在'filterBarGamesIndex' –
我同意,但是我的系統中不存在這樣的文件:/ –
您使用的瀏覽器是什麼?如果您使用的是Firefox,您可以在[Mozilla頁面]上試用'console.log(err.lineNumber)'(https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Error )。 – brennanenanen