Report client side errors to server

This commit is contained in:
James Allen 2014-07-24 16:07:43 +01:00
parent 4abf6ed38c
commit fb98509789
2 changed files with 25 additions and 8 deletions

View file

@ -50,7 +50,10 @@ define [
@$scope.editor.opening = true
@_openNewDocument doc, (error, sharejs_doc) =>
if error?
@ide.showGenericServerErrorMessage()
@ide.showGenericMessageModal(
"Error opening document"
"Sorry, something went wrong opening this document. Please try again."
)
return
@$scope.$broadcast "doc:opened"

View file

@ -7,14 +7,28 @@ define [
ide = {}
ide.$http = $http
ide.pushEvent = () ->
#console.log "PUSHING EVENT STUB", arguments
@recentEvents = []
ide.pushEvent = (type, meta = {}) =>
@recentEvents.push type: type, meta: meta, date: new Date()
if @recentEvents.length > 40
@recentEvents.shift()
ide.reportError = () ->
console.log "REPORTING ERROR STUB", arguments
ide.showGenericServerErrorMessage = () ->
console.error "GENERIC SERVER ERROR MESSAGE STUB"
ide.reportError = (error, meta = {}) =>
meta.client_id = @socket?.socket?.sessionid
meta.transport = @socket?.socket?.transport?.name
meta.client_now = new Date()
meta.recent_events = @recentEvents
errorObj = {}
if typeof error == "object"
for key in Object.getOwnPropertyNames(error)
errorObj[key] = error[key]
else if typeof error == "string"
errorObj.message = error
$http.post "/error/client", {
error: errorObj
meta: meta
_csrf: window.csrfToken
}
ide.showGenericMessageModal = (title, message) ->
$modal.open {