effect-http icon indicating copy to clipboard operation
effect-http copied to clipboard

Feature Request: Client should return all expected status codes

Open TylorS opened this issue 10 months ago • 3 comments

At present a Client derived from an API loses all type-safety in regards to any non-2xx status codes which are returned directly when making use of the Client's methods.

The way to recover access errors are via ClientError. The server-side ClientError's, which do have a status, are typed as unknown and must be re-validated manually to ensure type-safety on the client-side by hand.

In an ideal world I think these would be strongly typed by default by using the "success" channel of Effect to return all "expected", as defined by your API, instead of only 2xx status codes. This allows for type-safe transformation of all "expected" status codes into domain-specific values and/or failures to correspond with these other expected conditions.

Prior Discussion: https://github.com/sukovanej/effect-http/pull/515

TylorS avatar Apr 18 '24 03:04 TylorS