Effect CommunityEC
Effect Community16mo ago
9 replies
adrian_g

Challenges in Modeling Error Responses with HttpApi for 3rd Party API

I'm trying to use HttpApi to model a 3rd party api which I don't control. The reason I'm not going with plain HttpClient is that I like to be able to auto-generate a mock server for it (like effect-http dose with it's ExampleServer). However I'm facing some issues with modeling error responses. For example, I've got an error response which returns plain text body, but adding it as follows:
  HttpApiGroup.addError(
    HttpApiSchema.Text({ contentType: 'text/plain' }),
    { status: 409 },
  ),


doesn't work, it's still being parsed as json which leads to following error:
      _tag: 'ResponseError',
      [cause]: SyntaxError: Unexpected token 's', "some error" is not valid JSON
Was this page helpful?