forked from developmentseed/bones
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a window.onerror handler to show client side errors in the consol…
…e while debugging
- Loading branch information
Showing
4 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,9 @@ | |||
window.onerror = function(message, url, line) { | |||
$.ajax('/api/Error', { | |||
data: { | |||
message: message, | |||
url: url, | |||
line: line | |||
} | |||
}); | |||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,16 @@ | |||
var env = process.env.NODE_ENV || 'development'; | |||
|
|||
server = Bones.Server.extend({ | |||
initialize: function(app) { | |||
_.bindAll(this, 'logError'); | |||
if (env === 'development') { | |||
this.get('/api/Error', this.logError); | |||
} | |||
}, | |||
|
|||
logError: function(req, res, next) { | |||
console.error("Client Error: %s\n at %s:%d", | |||
req.query.message, req.query.url, req.query.line); | |||
res.send(); | |||
} | |||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters