herbs icon indicating copy to clipboard operation
herbs copied to clipboard

Hard to identify the reason of an error

Open eduardo-vortx opened this issue 4 years ago • 5 comments

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:

image

And that entity is the response of my usecase:

image

If I push an object that isn't an entity (does not implements BaseEntity), it throws an error at runtime:

image

image

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.

eduardo-vortx avatar Jan 10 '22 21:01 eduardo-vortx

Hi @eduardo-vortx, thanks for your contribution.

Did you think about any solutions (in a tech way) for this issue yet?

jhomarolo avatar Feb 10 '22 14:02 jhomarolo

Why not just fix the error? 🤷🏻‍♂️

italojs avatar Feb 14 '22 14:02 italojs

@eduardo-vortx this issue stil alive?

italojs avatar May 04 '22 23:05 italojs

@italojs this issue is not about fixing the error. It is about showing us that it is hard to find the error.

jhomarolo avatar Jul 25 '22 02:07 jhomarolo

@eduardo-vortx did you tried to use herbs audit inside the env?

jhomarolo avatar Jul 25 '22 02:07 jhomarolo