Michael Friend
07/24/2025, 5:48 PMHttpClientError
(UnsuccessfullResp, ResponseParse etc) to report more http related generic errors, and i have client classes for various apis that use these functions but want to basically add some more api specific errors like FilteringError
to the signature of those client functions, to make the overall error type of these essentially HttpClientError | MyApiSpecificError
(or maybe even more fine tuned if some end points have possible logic errors that others dont). Solutions Ive used in the past are this quick and dirty method of just doing interface HttpClientError: MyApiAError, MyApiBError
but that obviously gets gross fast, or what i assume is the recommended approach of having MyApiError
have a subclass that wraps any HttpClientError
. Is the latter the most "functional idiomatic" approach or is there something that doesnt require writing code to wrap HttpClient error in every call?Michael Friend
07/24/2025, 5:51 PMcontext(_: HttpClientError, _: MyApiAError)
but i find the api of dealing with multiple raise types a little clunkysimon.vergauwen
07/28/2025, 7:53 AMbut i find the api of dealing with multiple raise types a little clunkyIt's indeed a bit clunky since it requires n-nested
recover
to handle all n
errors.
I hope that this will become obsolete, or redundant, with rich errors though 🤞
I think for now writing the additional code, or providing some utilities for them is the best way of dealing with them.Michael Friend
07/28/2025, 5:50 PMDomainError
hierarchy with a wrapper is more common atm. Its definitely more backwards compatiblesimon.vergauwen
07/28/2025, 5:54 PMMichael Friend
07/28/2025, 5:58 PM