Title: Refactor error handling code · Issue #138 · josegonzalez/python-github-backup · GitHub
Open Graph Title: Refactor error handling code · Issue #138 · josegonzalez/python-github-backup
X Title: Refactor error handling code · Issue #138 · josegonzalez/python-github-backup
Description: As I was working on writing new error handling code for release asset downloading and trying to reuse the existing error handling for that purpose, I noticed that the _get_response and associated functions seem to need some significant r...
Open Graph Description: As I was working on writing new error handling code for release asset downloading and trying to reuse the existing error handling for that purpose, I noticed that the _get_response and associated f...
X Description: As I was working on writing new error handling code for release asset downloading and trying to reuse the existing error handling for that purpose, I noticed that the _get_response and associated f...
Opengraph URL: https://github.com/josegonzalez/python-github-backup/issues/138
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Refactor error handling code","articleBody":"As I was working on writing new error handling code for release asset downloading and trying to reuse the existing error handling for that purpose, I noticed that the `_get_response` and associated functions seem to need some significant refactoring.\r\n\r\nFor example, it looks like they were meant to be written to collect errors during the retry process, but that's not how they're being used in practice.\r\n\r\nFor example `_request_http_error` takes in an errors list which is also returns, but it never actually adds any errors to it. Then in `_get_response`, there is also an errors array (which is passes to `_request_http_error` presumably to collect any errors) and also returns, but it never gets added to there either.\r\n\r\nThen `_request_url_error` (which is called whenever a URLError or socket.error happens in `_get_response`) calls log_error which immediately exits the script before it can return. Then if it could return, `_get_response` would immediately raise an exception which is not caught, so the script would die before any error handling could happen anyway.\r\n\r\nDue to this, there are many cases of errors that should be recoverable that will kill the script, which isn't great if using it as a \"set it and forget it\" cron job.\r\n\r\nI started refactoring the asset downloading to share those same error handling functions, but then those needed refactoring, which meant `retrieve_data_gen` needed refactoring (it seems the real error handling is actually happening there right now in the cases the script doesn't die first).\r\n\r\nI'm going to put this aside for the moment so I can look at it with a fresh head later and work on one of the other simpler tickets I posted for the time being then come back to this.\r\n\r\nIdeally, after refactoring this to better handle errors, a command line switch (maybe something like `--strict-error-handling` or something) should be added to allows users to choose to exit on errors if they want while defaulting to gracefully handling errors, logging what failed, and continuing. To help with that, it may also be worthwhile generating a separate error log file that is stored somewhere that includes only failed items so they can be retried.\r\n\r\nAlso as mentioned in https://github.com/josegonzalez/python-github-backup/issues/73, we should no longer log empty wikis as warnings/errors as it gives the impression of errors when in reality there was no error (it just tried to clone the wiki and it didn't exist, not that it failed to clone a repo).\r\n\r\nRelated to https://github.com/josegonzalez/python-github-backup/issues/129, https://github.com/josegonzalez/python-github-backup/issues/110, and https://github.com/josegonzalez/python-github-backup/pull/130\r\n\r\nAlso likely related to https://github.com/josegonzalez/python-github-backup/issues/140","author":{"url":"https://github.com/einsteinx2","@type":"Person","name":"einsteinx2"},"datePublished":"2020-01-07T14:08:03Z","url":"https://github.com/josegonzalez/python-github-backup/issues/138"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:7b6a1bbe-999e-c60e-18c1-b3a997204978 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CF00:3D78AF:24033C:309D94:6B05DCDA |
| html-safe-nonce | 56b79fec84d6b39ac86802d95524308d293f36fabc90162b61e2a571f997d8c1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRjAwOjNENzhBRjoyNDAzM0M6MzA5RDk0OjZCMDVEQ0RBIiwidmlzaXRvcl9pZCI6Ijg0NDA0MzEzODY0MjY3Mjc2NDIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 8d3cf69723d1b47e0f7ec9656dad33bdd83b08ab3b1fc1340fd9087c83dd4e56 |
| hovercard-subject-tag | issue:546303406 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/josegonzalez/python-github-backup/138/issue_layout |
| twitter:image | https://opengraph.githubassets.com/96469f72b773f2660833d597cc9a80865165521be4f64a3857be9640252dd774/josegonzalez/python-github-backup/issues/138 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/96469f72b773f2660833d597cc9a80865165521be4f64a3857be9640252dd774/josegonzalez/python-github-backup/issues/138 |
| og:image:alt | As I was working on writing new error handling code for release asset downloading and trying to reuse the existing error handling for that purpose, I noticed that the _get_response and associated f... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | einsteinx2 |
| hostname | github.com |
| expected-hostname | github.com |
| None | ab9d6b164c6e5b32656ef80f1a302b2dafee4e4c9360ef3fced66da06fb522fa |
| turbo-cache-control | no-preview |
| go-import | github.com/josegonzalez/python-github-backup git https://github.com/josegonzalez/python-github-backup.git |
| octolytics-dimension-user_id | 65675 |
| octolytics-dimension-user_login | josegonzalez |
| octolytics-dimension-repository_id | 14876085 |
| octolytics-dimension-repository_nwo | josegonzalez/python-github-backup |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 14876085 |
| octolytics-dimension-repository_network_root_nwo | josegonzalez/python-github-backup |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 2db8c3558610af6beef9310dcf5537e201a6e5fb |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width