-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated client API and added new exceptions
- Loading branch information
Showing
2 changed files
with
163 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,68 @@ | ||
class SQSException(Exception): | ||
"""Custom exception for handling SQS specific errors.""" | ||
import sys | ||
from nistoar.pdr.preserv import PreservationException | ||
|
||
|
||
class ArchivingException(PreservationException): | ||
""" | ||
Base exception for all archiving-related errors within the archiving client. | ||
This exception is used as the base class for all exceptions raised specifically | ||
in the context of archiving operations, providing a unified way to handle all | ||
archive-related errors. | ||
""" | ||
|
||
def __init__(self, msg=None, errors=None, cause=None): | ||
""" | ||
Initialize the ArchivingException with a message, a list of detailed errors, and an optional cause. | ||
:param msg str: A message describing the error. | ||
:param errors list: A list of specific error messages with details. | ||
:param cause Exception: An underlying cause in the form of an Exception. | ||
""" | ||
super().__init__(msg=msg, errors=errors, cause=cause) | ||
|
||
|
||
class SQSException(ArchivingException): | ||
""" | ||
Specific exception for handling errors related to interactions with AWS SQS. | ||
This subclass captures exceptions that are specific to SQS operations and provides | ||
more detail. | ||
""" | ||
|
||
def __init__(self, original_exception, message=None): | ||
self.original_exception = original_exception | ||
if message is None: | ||
message = f"An error occurred with SQS: {str(original_exception)}" | ||
super().__init__(message) | ||
""" | ||
Initialize the SQSException with the original exception thrown by AWS SQS and an optional custom message. | ||
:param original_exception Exception: The original exception thrown by AWS SQS. | ||
:param message str: Optional custom message to provide additional context about the error. | ||
""" | ||
default_message = f"An error occurred with SQS: {str(original_exception)}" | ||
super().__init__( | ||
msg=message if message else default_message, cause=original_exception | ||
) | ||
|
||
|
||
class ValidationException(ArchivingException): | ||
""" | ||
An exception indicating a failure in validating data against predefined schemas | ||
or rules within the archiving process. | ||
This exception is used to highlight problems with the data being processed that | ||
do not meet the required standards or expectations, such as format, completeness, | ||
or logical consistency. | ||
""" | ||
|
||
def __init__(self, message, errors=None, cause=None): | ||
""" | ||
Initializes a new instance of ValidationException. | ||
:param message str: A general message describing the validation failure. | ||
:param errors list: A list of specific error messages providing | ||
detailed information about what failed during | ||
validation. | ||
:param cause Exception: An underlying cause in the form of an | ||
Exception instance, providing more context | ||
about the source of the failure. | ||
""" | ||
super().__init__(msg=message, errors=errors, cause=cause) |