Effect-TS / effect

An ecosystem of tools for building production-grade applications in TypeScript.

Home Page:https://effect.website

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add Cause.spans

jessekelly881 opened this issue · comments

What is the problem this feature would solve?

I'm trying to test whether certain spans have been added and currently the only way to do that is by calling cause.toString() and testing against the error message string.

What is the feature you are proposing to solve the problem?

It would be nice to be able to get a list(or maybe a tree?) of the current spans when working with a Cause. The spans are available in the cause.toString() message but not on the object itself.

What alternatives have you considered?

No response

spans are attached to error objects so there is no concept of spans in a cause

I see. Is there a better way of doing this than parsing the stack trace?

you could so Cause.prettyErrors(cause) that will give you a list of PrettyError instances, then each error will have a .span property that you can access

Oh beautiful. Thanks @mikearnaldi