Closed johanbrook closed 8 years ago
Hmm, this is making me think that all mixins should have a well-defined name
property. Also, it's weird that the stack trace in this error will actually show the validated-method
package, so in the worst case you'll get "One of the mixins didn't return an options object" and the trace will be from this package. I guess you will be able to use that to figure out which method it is.
Thoughts?
I'm thinking at the least the error message should include the name
of the ValidatedMethod in which the mixin was used, if such exists.
Hmm, this is making me think that all mixins should have a well-defined name property.
I hear you, but it might take the simplicity with "it's just functions" away.
I'm thinking at the least the error message should include the name of the ValidatedMethod in which the mixin was used, if such exists.
Yes, that's valid :) I'll fix.
At least the trace will point to the location where the ValidatedMethod
was instantiated. And it might perhaps be possible to pass the mixin in question as a parameter to the Error
thrown, as an extra data item?
Nah I think you're right - for now just adding the name of the method will be fine.
@stubailo Pushed.
As you can see in the tests, the error messages are now:
Error in methodWithFaultySchemaMixin method: The function 'nonReturningFunction' didn't return the options object
resp.
Error in methodWithFaultySchemaMixin method: One of the mixins didn't return the options object
Looks great!
:zap: :smile:
Fixes #23.
@stubailo I'm throwing inside of the
applyMixins
function instantly if the mixin in theforEach
callback isn't returning a plain object.name
property. Also, it's weird that the stack trace in this error will actually show thevalidated-method
package, so in the worst case you'll get "One of the mixins didn't return an options object" and the trace will be from this package. I guess you will be able to use that to figure out which method it is. Thoughts?name
of the ValidatedMethod in which the mixin was used, if such exists.resp.