Skip to content

errors: improve invalid arg type

I reworked the ERR_INVALID_ARG_TYPE error type in a way that provides more information to the user than before. All of these errors now return what was actually provided and failed. The information about what was provided and what is expected is more specific (as in not only the type is checked but also the constructor). I also fixed a few typos and wrong usages like using typeof arg as actual value instead of arg and one entry that actually checks a property, not an argument.

There is one point that might be thought about: mixing multiple expected values can only print either instance of or type of. So ['Array', 'string'] will result in instance of Array or string and not instance of Array or type of string. I could test each entry but I feel that is somewhat unnecessary?

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

errors

Merge request reports

Loading