Skip to content

Commit 2d6987c

Browse files
committed
adding unique MetadataRetrivalError class for identifying metadata errors and passing to handler
1 parent 260d7d0 commit 2d6987c

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/utils/metakg/metakg_errors.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class MetadataRetrievalError(Exception):
2+
"""Custom exception for metadata retrieval failures."""
3+
4+
def __init__(self, status_code, message):
5+
self.status_code = status_code
6+
self.message = message
7+
super().__init__(f"MetadataRetrievalError {status_code}: {message}")
8+
9+
def to_dict(self):
10+
"""Return error details in JSON-like dictionary format."""
11+
return {
12+
"code": self.status_code,
13+
"success": False,
14+
"error": "Metadata Retrieval Error",
15+
"details": str(self)
16+
}

0 commit comments

Comments
 (0)