Skip to content

Commit

Permalink
Merge pull request #113 from KrunchMuffin/master
Browse files Browse the repository at this point in the history
Updated bugLogClient.js to include comments about Chrome errors and more inclusive window.onerror sample
  • Loading branch information
oarevalo committed Sep 18, 2015
2 parents 3c0083a + 1c76dbe commit 9a1d15f
Showing 1 changed file with 29 additions and 8 deletions.
37 changes: 29 additions & 8 deletions client/bugLogClient.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
/* BugLogHQ Javascript Notification Client ( https://github.com/oarevalo/BugLogHQ )
*
**********
PLEASE NOTE... you will get errors like the following in Chrome...
"Resource interpreted as Script but transferred with MIME type text/html:"
OR
"Refused to execute script from 'buglog/listeners/bugLogListenerREST.cfm?message=...' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled."
To get around this, create a copy of 'buglog/listeners/bugLogListenerREST.cfm' and name it 'buglog/listeners/bugLogListenerRESTjs.cfm'
and add the following line to the top <cfheader name="Content-type" value="application/javascript">
**********
* Usage:
* <script type="text/javascript" src="bugLogClient.js"></script>
<script>
Expand All @@ -19,14 +27,27 @@
}
// Method 2: Within a global error handler (no stacktrace)
window.onerror = function(message, file, line) {
BugLog.notifyService({
message: message,
extraInfo: 'Error occurred in: ' + file + ':' + line,
severity:"ERROR"
});
return true;
};
// UPDATED. Taken from Stackoverflow user Sam. See http://stackoverflow.com/a/10556743/112680
window.onerror = function(msg, url, line, col, error) {
// Note that col & error are new to the HTML 5 spec and may not be
// supported in every browser. It worked for me in Chrome.
var extra = !col ? '' : '\ncolumn: ' + col;
extra += !error ? '' : '\nerror: ' + error;
// You can view the information in an alert to see things working like this:
alert("Error: " + msg + "\nurl: " + url + "\nline: " + line + extra);
BugLog.notifyService({
message: "JS Error: "+msg,
error: "url: " + url + "<br>line: " + line + extra,
severity: "ERROR"
});
var suppressErrorAlert = true;
// If you return true, then error alerts (like in older versions of
// Internet Explorer) will be suppressed.
return suppressErrorAlert;
};
</script>
*/

Expand Down

0 comments on commit 9a1d15f

Please sign in to comment.