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

feat: Include details for web api errors #483

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.7.6
3.2.0
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let me know if you want me to remove this from the PR 😅

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably, but this is just the default version being used, it has little consequence on anything. We should probably just delete this file.

6 changes: 6 additions & 0 deletions lib/slack/web/api/errors/slack_error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ def errors
def response_metadata
response.body.response_metadata
end

def to_s
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the approach I took here is to put as many details as possible but without empty details i.e. the errors list would not be added if there are none, same as the response metadata.

errors_message = ", errors=#{errors}" unless errors.nil?
response_metadata_message = ", response_metadata=#{response_metadata}" unless response_metadata.nil?
"#{error}#{errors_message || ''}#{response_metadata_message || ''}"
end
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/slack/web/api/errors/slack_error_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
rescue described_class => e
expect(e.response).not_to be_nil
expect(e.response.status).to eq 200
expect(e.message).to eql 'invalid_arguments'
expect(e.message).to eql "invalid_arguments, response_metadata=#{e.response_metadata}"
expect(e.error).to eql 'invalid_arguments'
expect(e.response_metadata).to eq(
'messages' => [
Expand Down