-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
977 additions
and
321 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
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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
""" | ||
A module containing different exceptions which could be useful. | ||
... | ||
Classes | ||
------- | ||
PQException | ||
Base class for exceptions in this module. | ||
ElementNotFoundError | ||
Exception raised if the given element id is not valid | ||
TrajectoryFormatError | ||
Exception raised if the given enum is not valid | ||
""" | ||
|
||
from beartype.typing import Any | ||
|
||
|
||
class PQException(Exception): | ||
""" | ||
Base class for exceptions in this module. | ||
""" | ||
|
||
def __init__(self, message: str) -> None: | ||
self.message = message | ||
super().__init__(self.message) | ||
|
||
|
||
class ElementNotFoundError(PQException): | ||
""" | ||
Exception raised if the given element id is not valid | ||
""" | ||
|
||
def __init__(self, id: Any) -> None: | ||
self.id = id | ||
self.message = f"""Id {self.id} is not a valid element identifier.""" | ||
super().__init__(self.message) | ||
|
||
|
||
class FormatEnumError(PQException): | ||
""" | ||
Exception raised if the given enum is not valid | ||
""" | ||
|
||
def __init__(self, value: object, enum: object) -> None: | ||
self.enum = enum | ||
self.value = value | ||
self.message = f""" | ||
'{self.value}' is not a valid {enum.__name__}. | ||
Possible values are: {enum.member_repr()} | ||
or their case insensitive string representation: {enum.value_repr()}""" | ||
super().__init__(self.message) | ||
|
||
|
||
class TrajectoryFormatError(FormatEnumError): | ||
""" | ||
Exception raised if the given enum is not valid | ||
""" | ||
|
||
def __init__(self, value: object, enum: object) -> None: | ||
super().__init__(value, enum) | ||
|
||
|
||
class MDEngineFormatError(FormatEnumError): | ||
""" | ||
Exception raised if the given enum is not valid | ||
""" | ||
|
||
def __init__(self, value: object, enum: object) -> None: | ||
super().__init__(value, enum) |
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
Oops, something went wrong.