Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Better logging of exceptions, fix sync problem
  • Loading branch information
ewels committed May 11, 2021
commit 45d843e7318d1086db9863f10cc0047f550c28ab
10 changes: 8 additions & 2 deletions nf_core/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import re
import requests
import requests_cache
import rich
import shutil
import time

Expand Down Expand Up @@ -323,6 +324,8 @@ def make_pull_request(self):
"base": self.from_branch,
}

stderr = rich.console.Console(stderr=True, force_terminal=nf_core.utils.rich_force_colors())

while True:
try:
log.debug("Submitting PR to GitHub API")
Expand All @@ -336,12 +339,14 @@ def make_pull_request(self):
)
try:
self.gh_pr_returned_data = json.loads(r.content)
returned_data_prettyprint = json.dumps(self.gh_pr_returned_data, indent=4)
r_headers_pp = json.dumps(r.headers, indent=4)
returned_data_prettyprint = json.dumps(dict(self.gh_pr_returned_data), indent=4)
r_headers_pp = json.dumps(dict(r.headers), indent=4)
except:
self.gh_pr_returned_data = r.content
returned_data_prettyprint = r.content
r_headers_pp = r.headers
log.error("Could not parse JSON response from GitHub API!")
stderr.print_exception()

# Dump the responses to the log just in case..
log.debug(f"PR response from GitHub. Data:\n{returned_data_prettyprint}\n\nHeaders:\n{r_headers_pp}")
Expand Down Expand Up @@ -372,6 +377,7 @@ def make_pull_request(self):
f"GitHub API returned code {r.status_code}: \n\n{returned_data_prettyprint}\n\n{r_headers_pp}"
)
except Exception as e:
stderr.print_exception()
raise PullRequestException(
f"Something went badly wrong - {e}: \n\n{returned_data_prettyprint}\n\n{r_headers_pp}"
)
Expand Down