mercredi 1 juillet 2015

ember.js: how to get name of controller / initializer / ect you are currently in?

I override Ember.deprecate() and Ember.warn() functions and I'm trying to understand where the warning / deprecation is coming from.

Problem is - I couldn't find any way to get the name of the controller / initializer / etc I'm called from, and generating an error to get the stacktrace return something like this:

at new Error (native)
at Error.EmberError (http://localhost:8000/static/assets/vendor.js:22707:21)
at Object.eval (eval at evaluate (unknown source), <anonymous>:1:9)
at Object.InjectedScript._evaluateOn (<anonymous>:895:55)
at Object.InjectedScript._evaluateAndWrap (<anonymous>:828:34)
at Object.InjectedScript.evaluateOnCallFrame (<anonymous>:954:21)
at Object.Ember.default.deprecate (http://localhost:8000/static/assets/agent.js:50:4)
at Object.Registry.lookup (http://localhost:8000/static/assets/vendor.js:12173:26)
at Object.<anonymous> (http://localhost:8000/static/assets/vendor.js:59653:45)
at Object.__exports__.default [as load] (http://localhost:8000/static/assets/vendor.js:60876:20)"

Which is pretty much useless..

So my question - how do I tell "where I am", eg what top level object caused the warning? In the example above it was called from an initializer but I want to know which one (filename would be enough for me).

PS. in case you wondered: the params deprecate() get is a short warning string and sometimes a url which lead to the docs explaining about the deprecation.

Thanks




Aucun commentaire:

Enregistrer un commentaire