Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: rename exceptions #118

Merged
merged 1 commit into from
Nov 12, 2023
Merged
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
22 changes: 11 additions & 11 deletions src/oaipmh_scythe/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,44 +5,44 @@
"""Custom exceptions for OAI-PMH related errors."""


class OAIPMHError(Exception):
class OAIPMHException(Exception):
"""Base exception for all OAI-PMH related errors."""


class BadArgument(OAIPMHError):
class BadArgument(OAIPMHException):
"""The request includes illegal arguments, is missing required arguments, includes a repeated argument,
or values for arguments have an illegal syntax."""


class BadVerb(OAIPMHError):
class BadVerb(OAIPMHException):
"""Value of the verb argument is not a legal OAI-PMH verb, the verb argument is missing,
or the verb argument is repeated."""


class BadResumptionToken(OAIPMHError):
class BadResumptionToken(OAIPMHException):
"""The value of the resumptionToken argument is invalid or expired."""


class CannotDisseminateFormat(OAIPMHError):
class CannotDisseminateFormat(OAIPMHException):
"""The metadata format identified by the value given for the metadataPrefix argument
is not supported by the item or by the repository."""


class IdDoesNotExist(OAIPMHError):
class IdDoesNotExist(OAIPMHException):
"""The value of the identifier argument is unknown or illegal in this repository."""


class NoSetHierarchy(OAIPMHError):
class NoSetHierarchy(OAIPMHException):
"""The repository does not support sets."""


class NoMetadataFormat(OAIPMHError):
class NoMetadataFormat(OAIPMHException):
"""There are no metadata formats available for the specified item."""


class NoRecordsMatch(OAIPMHError):
class NoRecordsMatch(OAIPMHException):
"""The combination of the values of the from, until, set and metadataPrefix arguments results in an empty list."""


class OAIError(OAIPMHError):
"""Context specific OAI errors not covered by the classes above."""
class GeneralOAIPMHError(OAIPMHException):
"""General exception for context-specific OAI-PMH errors not covered by the other specific classes."""
2 changes: 1 addition & 1 deletion src/oaipmh_scythe/iterator.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def _next_response(self) -> None:
exception_name = code[0].upper() + code[1:]
raise getattr(exceptions, exception_name)(description)
except AttributeError as exc:
raise exceptions.OAIError(description) from exc
raise exceptions.GeneralOAIPMHError(description) from exc
self.resumption_token = self._get_resumption_token()


Expand Down