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 @$scope.editor.opening = true
@_openNewDocument doc, (error, sharejs_doc) => @_openNewDocument doc, (error, sharejs_doc) =>
if error? if error?
@ide.showGenericServerErrorMessage() @ide.showGenericMessageModal(
"Error opening document"
"Sorry, something went wrong opening this document. Please try again."
)
return return
@$scope.$broadcast "doc:opened" @$scope.$broadcast "doc:opened"

View file

@ -7,14 +7,28 @@ define [
ide = {} ide = {}
ide.$http = $http ide.$http = $http
ide.pushEvent = () -> @recentEvents = []
#console.log "PUSHING EVENT STUB", arguments ide.pushEvent = (type, meta = {}) =>
@recentEvents.push type: type, meta: meta, date: new Date()
if @recentEvents.length > 40
@recentEvents.shift()
ide.reportError = () -> ide.reportError = (error, meta = {}) =>
console.log "REPORTING ERROR STUB", arguments meta.client_id = @socket?.socket?.sessionid
meta.transport = @socket?.socket?.transport?.name
ide.showGenericServerErrorMessage = () -> meta.client_now = new Date()
console.error "GENERIC SERVER ERROR MESSAGE STUB" 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) -> ide.showGenericMessageModal = (title, message) ->
$modal.open { $modal.open {