Hard to identify the reason of an error #22
Labels
enhancement
New feature or request
hacktoberfest
help wanted
Extra attention is needed
severity-major
Item is very important
Is your feature request related to a problem? Please describe.
Working on a project, I spent a good couple of hours strugling with a mistake I made.
In a scenario where a property of an entity is an array of another entity, like the image below:
And that entity is the response of my usecase:
If I push an object that isn't an entity (does not implements
BaseEntity
), it throws an error at runtime:Describe the solution you'd like
It would be nice to have a better error message, telling the developer he is pushing the wrong object to that array.
The example I created is very simple, so it's easier to identify the problem. But when I faced this problem, I was on a larger code base, so it took me a lot of time to understand what was going on.
Describe alternatives you've considered
Herbs is written in JS, so it's hard to handle this kind of errors because it only happens at runtime.
Thinking about the problem, may it would be possible to identify this by using Proxies on entity properties, so we can intercept the changes in the object and print a more specific message on the console.
Additional context
I created a minimal herbs project showing how to emulate the same problem.
The text was updated successfully, but these errors were encountered: