Skip to content

How do you map an error? #5

@derkbell

Description

@derkbell

First of all I have to say this is a great library, well documented, explaining the rationale as well. I just can't figure out the equivalent of mapError as it exists in rust. I often find the need to map errors like so:

return Result.fromAsyncCatching(fetch(url, options))
    .mapError((error) => new MyApplicationError('Fetching failed'))
    .map((response) => response.json())
    .mapError((err) => new MyApplicationError('JSON parsing failed'))

Is there an equivalent?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions