Open eduardo-vortx opened 2 years ago
Hi @eduardo-vortx, thanks for your contribution.
Did you think about any solutions (in a tech way) for this issue yet?
Why not just fix the error? 🤷🏻♂️
@eduardo-vortx this issue stil alive?
@italojs this issue is not about fixing the error. It is about showing us that it is hard to find the error.
@eduardo-vortx did you tried to use herbs audit inside the env?
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.