mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-23 23:58:02 -05:00
Let's try a heads-up whenever there's a JS error.
This commit is contained in:
parent
bbc1228c9c
commit
8a7e7e82a0
1 changed files with 14 additions and 0 deletions
|
@ -18,6 +18,7 @@ definitionSchemas =
|
||||||
'misc': require './schemas/definitions/misc'
|
'misc': require './schemas/definitions/misc'
|
||||||
|
|
||||||
init = ->
|
init = ->
|
||||||
|
watchForErrors()
|
||||||
path = document.location.pathname
|
path = document.location.pathname
|
||||||
testing = path.startsWith '/test'
|
testing = path.startsWith '/test'
|
||||||
demoing = path.startsWith '/demo'
|
demoing = path.startsWith '/demo'
|
||||||
|
@ -79,3 +80,16 @@ initializeServices = ->
|
||||||
for service in services
|
for service in services
|
||||||
service = require service
|
service = require service
|
||||||
service()
|
service()
|
||||||
|
|
||||||
|
watchForErrors = ->
|
||||||
|
currentErrors = 0
|
||||||
|
window.onerror = (msg, url, line, col, error) ->
|
||||||
|
return if currentErrors >= 3
|
||||||
|
return unless me.isAdmin() or document.location.href.search(/codecombat.com/) is -1 or document.location.href.search(/\/editor\//) isnt -1
|
||||||
|
++currentErrors
|
||||||
|
msg = "Error: #{msg}<br>Check the JS console for more."
|
||||||
|
#msg += "\nLine: #{line}" if line?
|
||||||
|
#msg += "\nColumn: #{col}" if col?
|
||||||
|
#msg += "\nError: #{error}" if error?
|
||||||
|
#msg += "\nStack: #{stack}" if stack = error?.stack
|
||||||
|
noty text: msg, layout: 'topCenter', type: 'error', killer: false, timeout: 5000, dismissQueue: true, maxVisible: 3, callback: {onClose: -> --currentErrors}
|
||||||
|
|
Loading…
Reference in a new issue