ts-results icon indicating copy to clipboard operation
ts-results copied to clipboard

Feature request: support error cause in `expect`

Open Jack-Works opened this issue 3 years ago • 3 comments

class Err {
    // ...
    expect(msg: string) {
        throw new Error(msg, { cause: this.val })
    }
}

Jack-Works avatar Aug 03 '21 04:08 Jack-Works

I think I'm asking about a similar thing here: https://github.com/vultix/ts-results/issues/48

@Jack-Works do you think the pattern in your opening post is the best way to resolve this?

jstasiak avatar Mar 29 '22 10:03 jstasiak

Error cause is a new JavaScript proposal to bring another Error in the current Error object.

image

Jack-Works avatar Mar 29 '22 10:03 Jack-Works

Thanks for the explanation, I like it. I'll add this to https://github.com/lune-climate/ts-results-es

jstasiak avatar Mar 29 '22 10:03 jstasiak