From c9925a3590f0b33799ff22fbff2801404aa52125 Mon Sep 17 00:00:00 2001 From: James Allen Date: Wed, 26 Oct 2016 11:34:05 +0100 Subject: [PATCH] Handle reporting of cyclic objects to Sentry --- .../directives/aceEditor/undo/UndoManager.coffee | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/services/web/public/coffee/ide/editor/directives/aceEditor/undo/UndoManager.coffee b/services/web/public/coffee/ide/editor/directives/aceEditor/undo/UndoManager.coffee index 9c61ce983d..40f1ba7c82 100644 --- a/services/web/public/coffee/ide/editor/directives/aceEditor/undo/UndoManager.coffee +++ b/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)