Vue: Better error message for undefined bound property

Created on 2 Aug 2016  Â·  6Comments  Â·  Source: vuejs/vue

Given the following:

<button :value.sync="missing">click</button>

results in the following error in the Chrome console:

Uncaught TypeError: Cannot read property 'length' of undefined

There is no mention:

  • that a bound property is missing
  • that its name is 'missing'
  • that it's on an element <button>
  • that it come from file foo.vue

An improvement would be to say:

Error: bound object 'missing' on element``<button>``can't be found in file foo.vue

contribution welcome feature request

Most helpful comment

its also an issue when accessing sub properties of non-existing properties.

e.g. {{options.title}} where options is not yet defined. IMHO it would be better to follow the angular way and just resolve string interpolations with errors to empty string and only log this error in non-release mode

All 6 comments

Similarly, this error could be more useful if it showed which component was trying to reference this element.

vue.common.js?f9a0:1019[Vue warn]: Unknown custom element: <component-a> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

thanks for the awesome project!!

Step into a similar error when using objects as props. If an element inside that object is bound to the template and the element is missing, the same error is thrown.

As it is a Javascript error, the browser ends the code executions and the page may not be rendered correctly.

It will be great if props of type object are checked for existence and all the child members of that object that are used in the template.

Just want to check the code to see if I can patch it... It seems that this error should be checked on the render function, right? Should I check in the vue template compiler then?

Thanks!

its also an issue when accessing sub properties of non-existing properties.

e.g. {{options.title}} where options is not yet defined. IMHO it would be better to follow the angular way and just resolve string interpolations with errors to empty string and only log this error in non-release mode

Do you guys have a gitter that I can join and receive some support in getting this issue assigned to me and worked on? I am a first timer to OSS!

@dmcfaddengalway We have, but I discourage you from starting with this feature because it's a 1.x feature request and pretty old

Here are the forum Discord server, and gitter

Was this page helpful?
0 / 5 - 0 ratings

Related issues

paulpflug picture paulpflug  Â·  3Comments

paceband picture paceband  Â·  3Comments

lmnsg picture lmnsg  Â·  3Comments

bdedardel picture bdedardel  Â·  3Comments

bfis picture bfis  Â·  3Comments