Skip to content

Enhancement: ApiError JSON parsing #12

Open

Description

@jaredmoody

The response_body field of the ApiError class is always a string - but sometimes it's a JSON string, and sometimes not.

So, to extract a meaningful error message i have to do something like:

message = 
  if error.response_headers['Content-Type'].include?('application/json')
    JSON.parse(error.response_body).dig('message')
  else
    error.response_body
  end

It seems parsing the response from the API should be a concern of the ApiError Class, what do you think about adding something that does this to the ApiError class? I'm happy to submit a PR if you like the idea.

Activity

  1. self-assigned this
    on Sep 20, 2019
  2. sowderca commented on Sep 24, 2019

    @sowderca
    Owner

    Hey @jaredmoody, I'd be happy to see this enhancement and to accept a PR implementing the change, I'll note that this gem is generated via openapi-generator using a combined spec produced from Save-ConnectWiseApiSpecs.ps1.

    I'm thinking that the change would have to be an override in order to limit manual changes to the code that's autogenerated.

    Let me know what you think

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions