Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support plain text errors #905

Open
ns-sjorgedeaguiar opened this issue Sep 3, 2024 · 2 comments
Open

Support plain text errors #905

ns-sjorgedeaguiar opened this issue Sep 3, 2024 · 2 comments

Comments

@ns-sjorgedeaguiar
Copy link

Hi,

I have a spec where the error message is of string type and the mime type is plaintext:

/some/path:
  post:
    responses:
      '200': ...
      '500':
        description: Server error
        content:
          text/plain; charset=utf-8:
            schema:
              type: string

This gets generated into a method returning Result<ResponseValue<_>, Error<ByteStream>>. The problem happens when deserialize the response:

match response.status().as_u16() {
    200u16 => ResponseValue::from_response(response).await,
    500u16 => Err(Error::ErrorResponse(ResponseValue::stream(response))),
    _ => Err(Error::UnexpectedResponse(response)),
}

The from_response method has a bound to fmt::Debug on the error type, which is not implemented for ByteStream, thus failing compilation.

I worked around it by simply removing the bound, but I'm wondering if there's a better solution. I can also open a PR to fix it if this workaround is good.

@AtlasPilotPuppy
Copy link

This might be related to trying to parse the error as json which would further raise an error

@ns-sjorgedeaguiar
Copy link
Author

hey @ahl
any thoughts on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants