File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change 1+ """
2+ This module defines custom exceptions that are raised in the `numcodecs` codebase.
3+ """
4+
5+ class UnknownCodecError (Exception ):
6+ """
7+ An exception that is raised when trying to receive a codec that has not been registered.
8+
9+ Parameters
10+ ----------
11+ codec_id : str
12+ Codec identifier.
13+ """
14+
15+ def __init__ (self , codec_id : str ):
16+ self .codec_id = codec_id
17+ super ().__init__ (f"codec not available: '{ codec_id } '" )
Original file line number Diff line number Diff line change 55from importlib .metadata import EntryPoints , entry_points
66
77from numcodecs .abc import Codec
8+ from numcodecs .errors import UnknownCodecError
89
910logger = logging .getLogger ("numcodecs" )
1011codec_registry : dict [str , Codec ] = {}
@@ -50,7 +51,7 @@ def get_codec(config):
5051 register_codec (cls , codec_id = codec_id )
5152 if cls :
5253 return cls .from_config (config )
53- raise ValueError ( f'codec not available: { codec_id !r} ' )
54+ raise UnknownCodecError ( f" { codec_id !r} " )
5455
5556
5657def register_codec (cls , codec_id = None ):
You can’t perform that action at this time.
0 commit comments