Skip to content

Consider adding a describe_error function to error typesΒ #914

@bcpeinhardt

Description

@bcpeinhardt

Howdy!

There's a particular pattern that's popped up in some Gleam packages, where modules that expose an error type Error also expose a fn describe_error(e: Error) -> String for stringifying said error. This functionality is especially helpful for logging in application code or using an ad hoc error type like the one provided in the snag package.

I wonder if we could implement this pattern in the stdlib. I have a PR showing what this might look like for the DecodeError type in the dynamic/decode package here. To be clear I have no strong opinions about the format of the error at the moment.

Off the top of my head, I don't know if any other module in the standard library exposes a custom error type.

I think a function like this might be useful for libraries using the decode module as well, for example: gleam/json exposes an error type that wraps the DecodeError

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions