0

We are trying to use loggly in our AngularJS/Breeze web portal and I am having some trouble when I am trying to send the error over the wire via $log.error (both the angular logging and loggly logging are in play here). Eventually there is a call to JSON.stringify which throws:

Converting circular structure to JSON

The problem is that the entityErrors array contains an array of entities where each entity contains an entityAspect which also contains the same entity which contains the same entityAspect which... yeah you get where I am going.

EntityAspect is automatically inserted by Breeze, so I am not sure how to get around this circular reference. Are there any gotchas that I haven't thought of that could be causing this recursive nesting, or is this just how the entityAspect functionality in Breeze works?

DavidActualX
  • 55
  • 1
  • 5
  • Looks like there are some alternatives to stringify here http://stackoverflow.com/questions/5410162/circumvent-error-converting-circular-structure-to-json-when-doing-json-stringify – Dylan May 07 '15 at 14:57

1 Answers1

1

You can avoid these problems if you can manage how you log errors.

Clearly just dumping the error object won't work for reasons you discovered. I cherry pick the error information I want to log. I generally don't dump the entityErrors; I select the tell-tale info from them that I truly need.

If I felt I had to dump them, I'd consider using EntityManager.exportEntities with the asString=false and includeMetadata=false options. This returns a JSON structure without circularities.

Ward
  • 17,793
  • 4
  • 37
  • 53