forked from zarr-developers/numcodecs
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Minor UX improvement: Add the
UnknownCodecError
. (zarr-developers#689)
* Add the UnknownCodecError * Remove trailing whitespace * Ruff formatting * Add a release note * Add doctest * Fix failing test case * Formatting again * Update numcodecs/tests/test_registry.py Co-authored-by: David Stansby <[email protected]> * Make UnknownCodecError inherit from ValueError --------- Co-authored-by: David Stansby <[email protected]>
- Loading branch information
Showing
4 changed files
with
32 additions
and
2 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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
""" | ||
This module defines custom exceptions that are raised in the `numcodecs` codebase. | ||
""" | ||
|
||
|
||
class UnknownCodecError(ValueError): | ||
""" | ||
An exception that is raised when trying to receive a codec that has not been registered. | ||
Parameters | ||
---------- | ||
codec_id : str | ||
Codec identifier. | ||
Examples | ||
---------- | ||
>>> import numcodecs | ||
>>> numcodecs.get_codec({"codec_id": "unknown"}) | ||
Traceback (most recent call last): | ||
... | ||
UnknownCodecError: codec not available: 'unknown' | ||
""" | ||
|
||
def __init__(self, codec_id: str): | ||
self.codec_id = codec_id | ||
super().__init__(f"codec not available: '{codec_id}'") |
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