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 #2335

Closed
manhg opened this Issue May 5, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@manhg

manhg commented May 5, 2017

Help us to manage our issues by answering the following:

  1. Describe your issue:
    It's hard to know which template expression is broken inside a tag.

I think this can give clearer info on what wrong by passing expression along with data

--- a/riot.js
+++ b/riot.js
@@ -597,7 +597,7 @@ var tmpl = (function () {
   function _tmpl (str, data) {
     if (!str) { return str }

-    return (_cache[str] || (_cache[str] = _create(str))).call(data, _logErr)
+    return (_cache[str] || (_cache[str] = _create(str))).call(data, _logErr.bind({data: data, tmpl: str}))
   }

   _tmpl.hasExpr = brackets.hasExpr;
@@ -621,10 +621,9 @@ var tmpl = (function () {
       typeof console !== 'undefined' &&
       typeof console.error === 'function'
     ) {
-      if (err.riotData.tagName) {
-        console.error('Riot template error thrown in the <%s> tag', err.riotData.tagName);
-      }
-      console.error(err);
+      console.error(err.message);
+      console.log('<%s> %s', err.riotData.tagName, this.tmpl);
+      console.log(this.data);
     }
   }
  1. Can you reproduce the issue?

Post the link using one of our bug report templates:

  1. On which browser/OS does the issue appear?

  2. Which version of Riot does it affect?
    3.4.4

  3. How would you tag this issue?

  • Question
  • Bug
  • Discussion
  • Feature request
  • Tip
  • Enhancement
  • Performance
@GianlucaGuarini

This comment has been minimized.

Show comment
Hide comment
@GianlucaGuarini

GianlucaGuarini May 5, 2017

Member

@manhg thanks for your feedback... could you please make a pull request here https://github.com/riot/tmpl?

Member

GianlucaGuarini commented May 5, 2017

@manhg thanks for your feedback... could you please make a pull request here https://github.com/riot/tmpl?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment