Skip to content

Commit 1b061ed

Browse files
committed
export_for_nextstrain.smk: catch Slack errors
The Slack messages are just a nice-to-have feature and should not cause the entire workflow to crash if there is an error. Prompted by <#1173 (comment)>
1 parent 1d37f03 commit 1b061ed

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

workflow/snakemake_rules/export_for_nextstrain.smk

+6-3
Original file line numberDiff line numberDiff line change
@@ -439,9 +439,12 @@ def send_slack_message(message, broadcast=False):
439439
exceptNoSuchEntryError:
440440
pass
441441

442-
response=requests.post("https://slack.com/api/chat.postMessage", headers=headers, data=json.dumps(data))
443-
response.raise_for_status()
444-
storage.store_if_not_present("slack_thread_ts", response.json()["ts"])
442+
try:
443+
response=requests.post("https://slack.com/api/chat.postMessage", headers=headers, data=json.dumps(data))
444+
response.raise_for_status()
445+
storage.store_if_not_present("slack_thread_ts", response.json()["ts"])
446+
exceptExceptionaserror:
447+
print("An error occurred when sending Slack message:", error)
445448

446449
# onstart handler will be executed before the workflow starts.
447450
onstart:

0 commit comments

Comments
 (0)
close