0

I'm trying to format AngularJS $log errors and send them to the server. My problem is I cannot figure out how to get the data.

Check out this fiddle to see my decorator in action.

Fiddle

What I'm having a hard time with is getting the desired data out from the first element in the array. It says the type is an object but when I try to iterate over the object I get nothing.

1 Answer 1

1

The problem is that your code isn't actually using the $log service. You have to use try{} catch(e){} to catch the error and then use $log.error(e) for that. I've modified the fiddle. Please take a look:

http://jsfiddle.net/Lvc0u55v/779/

Hope this helps. Thanks

EDIT:

The issue is that you're trying to iterate over an Error object :) it doesn't behave same as a normal object. If you want the data, you'll have to use obj.message and obj.stack respectively. Check my updated fiddle

http://jsfiddle.net/Lvc0u55v/787/

Sign up to request clarification or add additional context in comments.

3 Comments

Okay, I can't see what you modified there. I'm not sure how that helps me parse the object to get the data I want.
@tester123 .. Updated my answer.. Do check the fiddle.
Yes that helps! Thanks, your edits are much more clear

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.