Browse Source

Handle reporting of cyclic objects to Sentry

James Allen 10 years ago
parent
commit
c9925a3590

+ 9 - 1
services/web/public/coffee/ide/editor/directives/aceEditor/undo/UndoManager.coffee

@@ -233,8 +233,16 @@ define [
 			start = aceDelta.start
 			if !start?
 				error = new Error("aceDelta had no start event.")
+				JSONstringifyWithCycles = (o) ->
+					seen = []
+					return JSON.stringify o, (k,v) ->
+						if (typeof v == 'object')
+							if ( !seen.indexOf(v) )
+								return '__cycle__'
+							seen.push(v);
+						return v
 				Raven?.captureException(error, {
-					aceDelta: JSON.stringify(aceDelta)
+					aceDelta: JSONstringifyWithCycles(aceDelta)
 				})
 				throw error
 			linesBefore = docLines.slice(0, start.row)