Skip to content
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
Closed

Better error message #2335

manhg opened this issue May 5, 2017 · 1 comment

Comments

@manhg
Copy link

@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
Copy link
Member

@GianlucaGuarini 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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.