You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 29, 2022. It is now read-only.
Let's add a service to our app GithubErrorHandler.
It will have one method on it, with_error_handling which takes a block argument. We can call use it in our jobs to catch common errors.
This file can serve as a basic template: https://github.com/education/classroom/blob/master/lib/github/errors.rb. The main pieces that we want to copy are the with_error_handling method body and the big case statement that switches on errors. Though rather the just raising a different error, we will some appropriate action on the user.
Let's catch the following errors:
Let's add a new states to our state machine called dead. Also, let's add 1 new column to our user model, last_error, which will persist the last error.
In the ErrorHandler, let's have Octokit::AccountSuspended and UserNotFoundOnGithubError set the last_error column and move the user into the dead state. All other errors in the Handler that are not explicitly handled should be reraised.
We should also add code to not the TryUserTransition Job (and perhaps a few others) to not include Users in the dead state. We may want to use a default_scope to accomplish this, so long as it does not interfere with the state machine.
We may want to consider adding an error state later, or some additional way to handle our Ockokit::Unauthorized errors, but not in the scope of this PR.
The text was updated successfully, but these errors were encountered:
We're going to rename the proposed dead state to inactive, and the event to transition to this state will be called inactivate
The error handler will be renamed to UserErrorHandler and take two arguments: the user and the block. This way the user comes in wherever with_error_handling is called and does not need to be attached to the errors that the error handler deals with. The UserErrorHandler will remain a module
Let's add a service to our app
GithubErrorHandler
.It will have one method on it,
with_error_handling
which takes a block argument. We can call use it in our jobs to catch common errors.This file can serve as a basic template: https://github.com/education/classroom/blob/master/lib/github/errors.rb. The main pieces that we want to copy are the
with_error_handling
method body and the big case statement that switches on errors. Though rather the just raising a different error, we will some appropriate action on the user.Let's catch the following errors:
Let's add a new states to our state machine called
dead
. Also, let's add 1 new column to our user model,last_error
, which will persist the last error.In the ErrorHandler, let's have
Octokit::AccountSuspended
andUserNotFoundOnGithubError
set the last_error column and move the user into thedead
state. All other errors in the Handler that are not explicitly handled should be reraised.We should also add code to not the TryUserTransition Job (and perhaps a few others) to not include Users in the dead state. We may want to use a
default_scope
to accomplish this, so long as it does not interfere with the state machine.We may want to consider adding an
error
state later, or some additional way to handle ourOckokit::Unauthorized
errors, but not in the scope of this PR.The text was updated successfully, but these errors were encountered: