-
Notifications
You must be signed in to change notification settings - Fork 159
Display GitHub error message when module sync fails #348
base: master
Are you sure you want to change the base?
Display GitHub error message when module sync fails #348
Conversation
maybe we move the error catch also to the Line 201 in 8af567e
|
It's a largely cosmetic change anyway so I didn't put too much effort into writing a test for it...that whole controller is untested and needs a refactor to make that feasible. You're right though, if I mock the client instead of the collection I'd likely have an easier time. |
$repositories = $this->fetchModules($repos); | ||
$viewModel->setVariable('repositories', $repositories); | ||
} catch (GithubException $ex) { | ||
$viewModel->setVariable('error_message', $ex->getMessage()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
camelCase
? Also, above.
Not sure about passing through the actual exception message, as you pointed it out, but looks good to me! |
@localheinz thanks for the reivew. I've fixed the items you pointed out. As for returning the exception message it's not ideal but it's a good stop-gap to keep the spinner from spinning forever if there is a problem with the sync. Ideally EdpGithub or the RepositoryRetriever service would throw distinguishable exceptions (or at least exception messages we know to be safe to send back to the user) |
$repositories = $this->fetchModules($repos); | ||
$viewModel->setVariable('repositories', $repositories); | ||
} catch (GithubException $ex) { | ||
$viewModel->setVariable('errorMessage', $ex->getMessage()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should still set a 503
response code, even if the page is correctly generated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd still ask for a unit test of this functionality (mock with |
@Ocramius I mocked all the things; there are now four test cases covering the changes made in this PR |
Needs a rebase! |
c02896e
to
d48d962
Compare
This needs another rebase, sorry for letting it slip through, @adamlundrigan :( |
Can this be merged |
Ping @Ocramius @adamlundrigan |
It needs a rebase before it can be merged |
|
7359ab6
to
393f709
Compare
The code had changed so much I ditched my original and implemented it fresh, integrating your suggestions:
I was no longer able to reproduce the original API limit exceptions against GitHub (kudos to whomever fixed the sync 👍) but the principle behind the change is the same: catch any exception coming from EdpGithub and dump out an error message to the user. |
Catch the
RuntimeException
thrown by EdpGithub and send it back to the user.Two notes: