-
Notifications
You must be signed in to change notification settings - Fork 130
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
better error message #438
Comments
Thanks for calling this out, Johan. I agree the error message is not ideal, and that the additional information would be helpful, but unfortunately it looks like a fix is difficult to achieve. If it were possible at all it would imply significant changes and additions to the the template parsing code, with corresponding cost in perf, code size, and potentially stability of current code. So my current take is that this is a 'won't fix`. In fact the parsed code is |
What I'm discovering is that I come back to a month old code or more and change something, perhaps a web api or something in a viewmodel which result in a template all of a sudden being linked against a new data structure. Bang I'm getting this kind of error. At best of times it's easy to find out which template expression is the culprit but it happens all to often that I have to remove a lot of template code and by process of elimination locate the template expression that is causing the error. Perhaps a best effort would be enough. I'm noticing that the
What if instead the dynamic javascript was generated something like this instead?
Instead of hijacking the error it might be better to throw a custom error. I seem to recall there being a template parser error.. This shouldn't incur any performance penalty, code size should be small and it would at least print out the template expression I should be looking out for. |
Ah - well if you want to include a try catch, I believe there is a perf cost, but you can do it with existing features. Just do the following, as an opt-in choice:
(It is opt-in because of the trade-off perf/debugging information) See https://www.jsviews.com/#onerror@debugmode-function. You can also set onError on the tag, to pass in anything you want via the fallback parameter of your handler. It can be a string, an object or a function, such as the template object:
|
That first option does what I need. Thanks. |
Closing, since the requested feature is already available through existing feature: https://www.jsviews.com/#onerror@debugmode-function. |
This fiddle
html:
js:
gives the following unhelpful error message:
I would rather the error message mention the name of the context parameter, in this case "unknown".
It would also be helpful in tracking down the error if the exception would write out which template and tag hierarchy that threw the exception.
The text was updated successfully, but these errors were encountered: