-
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 691fbf5
Showing
5 changed files
with
73 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,20 @@ | ||
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__( | ||
f"{exception}\n\nThis error originates from an architecture, and is likely " | ||
"not a problem with metatensor-models." | ||
) |
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,11 @@ | ||
import pytest | ||
|
||
from metatensor.models.utils.errors import ArchitectureError | ||
|
||
|
||
def test_architecture_erro(): | ||
with pytest.raises(ArchitectureError, match="not a problem with metatensor-models"): | ||
try: | ||
raise ValueError("An example error from the architecture") | ||
except Exception as e: | ||
raise ArchitectureError(e) |