Closed kungfooman closed 8 months ago
I pretty much see two ways to unify warnings:
1) throw new Error('x is NaN')
in combination with try / catch
2) Giving each function a warn
method, the "parent" will just append all the calls to this callback
I'm tending to (2) since (1) may cause performance issues. I can also imagine that (2) will reduce circular dependency a bit, which is very welcome aswell, tracked in #54 (because we can remove the warn import declarations)
This may cause a somewhat bigger refactor, because I'm no longer happy about the name "assertType" - IMO it should be called either
validateType
or - even shorter -isType
- "assert" implies it will throw on wrong types, but it doesn't.And then I'm also contemplating to rename the validate-functions into assert-functions and actually make them throw type errors, so we can merge certain types into one longer type error string.
I specifically think about: customValidations-for-entity.mjs
Example:
What I want to see here is simply:
Entity#constructor> customValidation failed: x is NaN