slack-ruby / slack-ruby-client

A Ruby and command-line client for the Slack Web, Real Time Messaging and Event APIs.
MIT License
1.19k stars 214 forks source link

Error details aren't passed through #482

Open kevinrobayna opened 1 year ago

kevinrobayna commented 1 year ago

I see we have cassettes here https://github.com/slack-ruby/slack-ruby-client/blob/bf5bb4be3e03e9bd74d22942a61d5611f5c1d997/spec/fixtures/slack/web/views_open_error.yml#L79

but the error we get, if something fails, is just invalid_arguments, is this on purpose?

dblock commented 1 year ago

Do you mean it doesn't include response_metadata? We should, it's not on purpose.

kevinrobayna commented 1 year ago

Actually, the response metadata is present 😅

I was expecting when printing e that I'd get all the details from the error (instead I was only getting the error message)


        client.views_open(
          view: view,
          trigger_id: request[:trigger_id]
        )
      rescue Slack::Web::Api::Errors::InvalidArguments => e
        puts e # prints invalid_arguments
        puts e.error # prints invalid_arguments
        puts e.response_metadata # prints the error from slack's api
      end
kevinrobayna commented 1 year ago

Closing since people can get the error details as expected I was just being silly 😅

dblock commented 1 year ago

We could change to_s to display it.

kevinrobayna commented 1 year ago

yeah! raised a PR for it, let me know your thoughts

https://github.com/slack-ruby/slack-ruby-client/pull/483