Skip to content

Commit 0318816

Browse files
committed
improve error handling and reporting
1 parent 6c6d3dd commit 0318816

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

scripts/automated_ingestion/eessi_task.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from github import Github, GithubException, UnknownObjectException
99
from github.PullRequest import PullRequest
1010
import os
11+
import traceback
1112

1213

1314
class SequenceStatus(Enum):
@@ -501,13 +502,20 @@ def _create_symlink(self, source_path: str, target_path: str, branch: str = None
501502
try:
502503
new_tree = self.git_repo.create_git_tree([tree_element], base_tree)
503504
log_message(LoggingScope.TASK_OPS, 'INFO', "new tree created: %s", new_tree)
504-
except Exception as err:
505+
except GithubException as err:
505506
log_message(LoggingScope.TASK_OPS, 'ERROR', "Error creating new tree: %s", err)
506507
log_message(LoggingScope.TASK_OPS, 'ERROR', " Status Code: %s", err.status)
507508
log_message(LoggingScope.TASK_OPS, 'ERROR', " Error Message: %s", err.data)
508509
log_message(LoggingScope.TASK_OPS, 'ERROR', " Headers: %s", err.headers)
509510
log_message(LoggingScope.TASK_OPS, 'ERROR', " Raw Response: %s", err.response)
510511
return False
512+
except Exception as err:
513+
log_message(LoggingScope.TASK_OPS, 'ERROR', "\n=== General Exception ===")
514+
log_message(LoggingScope.TASK_OPS, 'ERROR', " Type: %s", type(err).__name__)
515+
log_message(LoggingScope.TASK_OPS, 'ERROR', " Message: %s", str(err))
516+
log_message(LoggingScope.TASK_OPS, 'ERROR', " Traceback:")
517+
log_message(LoggingScope.TASK_OPS, 'ERROR', " %s", traceback.format_exc())
518+
return False
511519

512520
# Create new commit
513521
commit_message = f"Add symlink {source_path} -> {target_path}"

0 commit comments

Comments
 (0)