Say I have some object
> var a = {'a': 1, 'b': 2}
undefined
> a.c
undefined
I would like it if this "undefined" attribute c
were to instead raise some sort of custom error.
Is there some way to over-ride my object's default behavior, or perhaps invoke it in some way as to provide a callback in case the lookup returns undefined
?
I found this question from a couple of years ago that appears related.
I ask because I feel generic TypeError: cannot call method 'foo' of undefined
errors might be better replaced with more meaningful feedback.