-
-
Notifications
You must be signed in to change notification settings - Fork 408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide access to template invocation stack in debug builds #643
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this @lukemelia!
|
||
The fact that that this will only be available in debug builds adds to complexity for consumers of the API and could potentially lead to errors in production if a developer does not realize this. | ||
|
||
## Alternatives |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another possible alternative would be to provide a public API to emit the same hierarchical message that is used for the backtracking assertion (which is what the on
and fn
PR linked to above uses). This doesn’t solve the problem 100% (it wouldn’t directly provide access to the line and column info), but it’s fairly close and the plumbing is already largely available (still requires owner
access though that might be mitigated by an argument as suggested in the api section). I think this would likely be much easier to implement and could be improved over time to include line and column info when we have solved question 3 above (and in fact, would mean that all of Embers other template error messages like the backtracking rerender one, or on/fn mentioned above, would get that info also).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rwjblue Thanks for the quick feedback. I incorporated this and the other feedback you left into the text of the RFC. Feel free to suggest changes if your intention can be expressed more clearly than I captured.
FYI - I brought this up at todays core team meeting. A few general notes/observations:
In the end, the core team decided to defer to a smaller group (the glimmer team) for more detailed feedback. I'll try to remember to chime back in here once we've had that discussion. |
We discussed this again at the most recent GlimmerVM team meeting, and think we have a viable path forward that we are confident we can support over time. We are thinking something like:
This could be used like: export default class extends Component {
renderLocation = getRenderInvocationInfo();
@action doSomething() {
if (someBadCondition()) {
throw new Error(`Don't do that! ${this.renderLocation}`);
}
}
} The fact that it returns an opaque string with the "best effort" promise means that it is quite likely that we can maintain this contract over time (vs providing more structured output like in We still need to decide exact method names and module paths, but the VM team is generally 👍 to this rough sketch. @lukemelia - What do you think? Do you think that is "enough" to satisfy the motivation here? |
@rwjblue I think this sounds like a good approach. I had originally thought of something structured so that the most useful error messages could be crafted, but this has obvious advantages and doesn't preclude exposing more structured detail it proves to be necessary in the future. 👍 |
@lukemelia - Just checking in here, have any time to update the doc? I think @pzuraq has most of the plumbing landed in glimmer-vm, so looking forward moving the API forward... |
I would just like to +1 this. I'm learning ember, and this would be extremely useful. Would make debugging and locating errors much faster, and the learning process smoother! |
@lukemelia just a reminder that this could use to be updated. |
This seems useful and sounds like it had some interest initially. Does this still make sense in the Polaris world and should we pick it back up? |
Rendered