Skip to content

ServerError does not descend from InternalError#380

Merged
dblock merged 8 commits intoslack-ruby:masterfrom
jmanian:server_error
Jun 23, 2021
Merged

ServerError does not descend from InternalError#380
dblock merged 8 commits intoslack-ruby:masterfrom
jmanian:server_error

Conversation

@jmanian
Copy link
Copy Markdown
Collaborator

@jmanian jmanian commented Jun 19, 2021

Resolves #373.

Notes:

  1. The change in class hierarchy is a breaking change for anyone who might be rescuing SlackError and expecting it to rescue ServerError.
  2. I took the suggestion from Handle server errors such as timouts & non-json responses #350 about syncing the message into the class definition rather than passing it in. This is a breaking change for anyone instantiating these errors in their code.
  3. I tweaked TooManyRequestsError to follow the same pattern for defining its message. Not a breaking change, just implementation.

Questions:

  1. Is it OK for these 5 error classes to share a file now that they're no longer empty definitions?
  2. I didn't do it here, but I'm tempted to change these 3 error messages to something more human readable rather than an underscore code. I assume the underscore messages were inspired by the error messages that Slack returns, but since these are not error messages from Slack they don't need to conform, and in fact it could be misleading if they look like they might be messages from Slack. For example UnavailableError could be "The server responded with #{status}". Thoughts on this? It could be considered a breaking change.
  3. I didn't do it yet, but I'm tempted to follow the same message pattern for all the descendants of SlackError defined in errors.rb, so that instead of Slack::Web::Api::Errors::AccountInactive.new('account_inactive', response) it's simply Slack::Web::Api::Errors::AccountInactive.new(response). This would be a breaking change for anyone instantiating these error classes.

To be done later, if this approach is good:

  • Add to changelog
  • Add an entry to upgrading.md
  • Move the version to 0.18.0 since this is a breaking change

@jmanian jmanian requested a review from dblock June 19, 2021 01:01
@jmanian jmanian marked this pull request as ready for review June 19, 2021 19:22
Copy link
Copy Markdown
Collaborator

@dblock dblock left a comment

Choose a reason for hiding this comment

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

This looks good. Care to cleanup my minor nits and I'll merge? Thank you.

Comment thread CHANGELOG.md Outdated
### 0.18.0 (Next)

* Your contribution here.
* [#380](https://github.com/slack-ruby/slack-ruby-client/pull/380): Updates to server error classes and hierarchy (see [UPGRADING](UPGRADING.md) for more) - [@jmanian](https://github.com/jmanian).
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

No need to mention UPGRADING here, or our CHANGELOG will be littered with them.

Comment thread README.md Outdated
##### Other Errors

In case of Slack temporarily unavailability a `Slack::Web::Api::Errors::ServerError` (`Slack::Web::Api::Errors::SlackError` subclass) subclasses will be raised and original `Faraday::Error` will be accesible via `exception.cause`.
In case of Slack temporarily unavailability a subclass of `Slack::Web::Api::Errors::ServerError` will be raised and original `Faraday::Error` will be accesible via `exception.cause`. (This is no longer a subclass of `Slack::Web::Api::Errors::SlackError`, see [UPGRADING](UPGRADING.md).)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let's write "Since version X.Y.Z this class is no longer ... and remove see UPGRADING.

Comment thread UPGRADING.md

As of 0.18.0 `Slack::Web::Api::Errors::ServerError` and its subclasses (introduced in 0.16.0) no longer extend `Slack::Web::Api::Errors::InternalError` or its parent `Slack::Web::Api::Errors::SlackError`. If you are rescuing `SlackError` or `InternalError` with the intention of including `ServerError` and its subclasses you should adjust your code to explicitly rescue `Slack::Web::Api::Errors::ServerError`.

Additionally the `initialize` method for `ParsingError`, `TimeoutError`, and `UnavailableError` have changed from `new(message, response)` to `new(response)`. The `message` is now built into the definition of these classes. If you are instantiating or raising these errors in your code (perhaps in tests) you will need to update your code.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe add some before/after?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

You mean example code before and after? I can do that

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yeah

@jmanian
Copy link
Copy Markdown
Collaborator Author

jmanian commented Jun 21, 2021

@dblock Where's Travis?

@dblock
Copy link
Copy Markdown
Collaborator

dblock commented Jun 21, 2021

@dblock Where's Travis?

Not sure. Did they turn off travis-ci.org finally? Want to move us to GitHub actions?

@dblock
Copy link
Copy Markdown
Collaborator

dblock commented Jun 21, 2021

@jmanian I enabled travis-ci.com on the org, maybe next push will "just work"? Let's upgrade badges...

@jmanian
Copy link
Copy Markdown
Collaborator Author

jmanian commented Jun 22, 2021

@dblock Still no Travis. I originally opened this PR as a draft, maybe that confused it? I authed into Travis to see if I could do anything but the repo doesn't appear for me there.

@dblock
Copy link
Copy Markdown
Collaborator

dblock commented Jun 23, 2021

@jmanian I am seeing https://travis-ci.com/github/slack-ruby/slack-ruby-client and it's enabled for PRs. Try making a new PR? Maybe that will kick it? I dunno. Rewrite everything in GitHub actions? :)

I tried to trigger a build, which failed with some unexpected error. So I clicked a bunch of buttons on travis-ci.com: added a free plan, signed up for "Beta", migrated repos to travis-ci.com. Then the trigger seems to have worked.

Try pushing again?

PS: All this seems unnecessary. Should get off Travis.

@jmanian
Copy link
Copy Markdown
Collaborator Author

jmanian commented Jun 23, 2021

@dblock Success!

@dblock dblock merged commit 7d53b51 into slack-ruby:master Jun 23, 2021
@dblock
Copy link
Copy Markdown
Collaborator

dblock commented Jun 23, 2021

Merged, merci.

@jmanian jmanian deleted the server_error branch June 28, 2021 16:02
olleolleolle added a commit to olleolleolle/slack-ruby-client that referenced this pull request Nov 16, 2021
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

Successfully merging this pull request may close these issues.

Suggestion: ServerError should not descend from InternalError or SlackError

2 participants