Skip to content

Commit e836ff1

Browse files
committed
improve error handling for GitHub authentication failures in codespaces
1 parent b2ebb8c commit e836ff1

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

submit50/__main__.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def check_slug_year(slug):
195195
# Ask if they want to continue
196196
if not re.match(f"^\s*(?:{_('y|yes')})\s*$", input(_("Do you want to continue with this submission (yes/no)? ")), re.I):
197197
raise Error(_("User aborted submission."))
198-
198+
199199
except ValueError:
200200
pass
201201

@@ -283,11 +283,15 @@ def main():
283283
try:
284284
user_name, commit_hash, message = lib50.push("submit50", args.slug, CONFIG_LOADER, prompt=prompt, auth_method=auth_method)
285285
except lib50.ConnectionError:
286-
LOGGER.debug(traceback.format_exc()) # log the traceback
287-
raise Error(_(
288-
"check50 failed to authenticate your Github account. Try running check50 again with --https or --ssh, "
289-
"or try restarting your codespace. If the problem persists, please email us at sysadmins@cs50.harvard.edu."
290-
))
286+
LOGGER.debug(traceback.format_exc())
287+
if not os.environ.get("CODESPACES"):
288+
raise Error(_(
289+
"submit50 failed to authenticate your Github account. Please make sure you are connected to the internet and try again."
290+
))
291+
except Exception as e:
292+
LOGGER.debug(traceback.format_exc())
293+
raise Error(_("Sorry, something's wrong, please try again.\n"
294+
"If the problem persists, please visit our status page https://cs50.statuspage.io for more information.")) from e
291295
print(message)
292296

293297
if __name__ == "__main__":

0 commit comments

Comments
 (0)