How can I get more stacktrace in AngularJS

后端 未结 1 766
有刺的猬
有刺的猬 2021-02-05 09:55

I\'m using the decorator to change the $exceptionHandler behavior, sending logs to the server. My problem with this is that the stackatrace of the exceptions seems

1条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-05 10:43

    1 Use a debugger, instead of Chrome console

    Google Chrome provides a debugger that helps JS programmers to find bugs and problematic code.

    As the complexity of JavaScript applications increase, developers need powerful debugging tools to help quickly discover the cause of a issue and fix it efficiently. The Chrome DevTools include several useful tools to help make debugging JavaScript less painful.

    You can try putting some breakpoints wherever you want (try to detect the problematic lines/ methods).

    See the official documentation here: Google Chrome Debugger

    2 Use a browser extension

    Many plugins like ng-inspector or AngularJS Batarang helps you to print the status of your AngularJS program (controller instances, variable names/values, and scopes).

    3 Use $log service (console.log wrapper)

    The AngularJS $log service provides a simple resource to print the status of your variables in the browser console (if present).

    Simple service for logging. Default implementation safely writes the message into the browser's console (if present).

    The main purpose of this service is to simplify debugging and troubleshooting.

    The default is to log debug messages. You can use ng.$logProvider#debugEnabled to change this. AngularJS $log service helps you to debug your program.


    From my point of view, a good AngularJS debug includes the combination of all the above solutions.

    I hope it is useful for you.

    0 讨论(0)
提交回复
热议问题