client: implement interface{ Is(error) bool }
on generated errors
#1413
Labels
interface{ Is(error) bool }
on generated errors
#1413
Problem
The template for generating errors only implements the
Error() string
interface.Since the generated error is a struct,
errors.Is()
cannot be used directly. The only way to check errors is to use the more cumbersomeerrors.As()
alternative.Proposal
Golang allows errors to implement the
interface{ Is(error) bool }
, which allows complex errors to be scanned witherrors.Is
. Something as straightforward as:Could allow one-line checks like this:
Or even allow for nice switch statements:
References
This feature would be insanely helpful for integration tests. Also it could improve code quality on applications that use the ogen client.
The text was updated successfully, but these errors were encountered: