Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
46 changes: 31 additions & 15 deletions agent-framework/prometheus_swarm/utils/errors.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
"""Error type for API errors."""
"""Custom exceptions for Prometheus Swarm framework."""


class ClientAPIError(Exception):
"""Error for API calls with status code."""

def __init__(self, original_error: Exception):
print(original_error)
if hasattr(original_error, "status_code"):
self.status_code = original_error.status_code
else:
self.status_code = 500
if hasattr(original_error, "message"):
super().__init__(original_error.message)
else:
super().__init__(str(original_error))
class DuplicateEvidenceError(Exception):
"""Exception raised when duplicate evidence is detected.

Attributes:
message (str): Explanation of the error
evidence_id (str, optional): Identifier of the duplicate evidence
"""

def __init__(self, message: str, evidence_id: str = None):
"""
Initialize the DuplicateEvidenceError.

Args:
message (str): Detailed error message
evidence_id (str, optional): Identifier of the duplicate evidence
"""
self.message = message
self.evidence_id = evidence_id
super().__init__(self.message)

def __str__(self):
"""
String representation of the error.

Returns:
str: Formatted error message with optional evidence ID
"""
if self.evidence_id:
return f"{self.message} (Evidence ID: {self.evidence_id})"
return self.message
Loading