chridou / http-api-problem

A problem type to be returned by HTTP APIs
Apache License 2.0
53 stars 12 forks source link

`IntoAPIError` and a derive macro for it #36

Closed SohumB closed 2 years ago

SohumB commented 2 years ago

This PR implements the IntoApiError trait and a derive macro for this trait.

This is for the usecase where clients want to use their own error types, but separately want to convert them into ApiError — possibly because the core of the application is written without reference to http, but each independent error can still be translated with reference to http problems and status codes. The derive macro is useful for cases where errors are built from enums of other errors, that already implement IntoApiError.

chridou commented 2 years ago

Thanks so much!