-
-
Notifications
You must be signed in to change notification settings - Fork 219
Consider adding a describe_error function to error typesΒ #914
Description
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