-
Notifications
You must be signed in to change notification settings - Fork 5
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
1 parent
56f2a64
commit 5a607ad
Showing
5 changed files
with
75 additions
and
20 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,21 @@ | ||
class ArchitectureError(Exception): | ||
""" | ||
Exception raised for errors originating from architectures | ||
This exception should be raised when an error occurs within an architecture's | ||
operation, indicating that the problem is not directly related to the | ||
metatensor-models infrastructure but rather to the specific architecture being used. | ||
:param exception: The original exception that was caught, which led to raising this | ||
custom exception. | ||
:type exception: The exception message includes the message of the original | ||
exception, followed by a note emphasizing that the error likely originates from | ||
an architecture. | ||
""" | ||
|
||
def __init__(self, exception): | ||
super().__init__( | ||
"The error below most likely originates from an architecture. If you think " | ||
"this is a bug, please contact its maintainer (see the architecture's " | ||
f"documentation).\n\n{exception}" | ||
) |
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,12 @@ | ||
import pytest | ||
|
||
from metatensor.models.utils.errors import ArchitectureError | ||
|
||
|
||
def test_architecture_error(): | ||
match = "The error below most likely originates from an architecture" | ||
with pytest.raises(ArchitectureError, match=match): | ||
try: | ||
raise ValueError("An example error from the architecture") | ||
except Exception as e: | ||
raise ArchitectureError(e) |