Skip to content

Commit

Permalink
Use appropriate error (KeyError) in HandlerTypeRegistry.get().
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 718148036
  • Loading branch information
BlaziusMaximus authored and Orbax Authors committed Jan 22, 2025
1 parent fb272d0 commit f7bbe80
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def get(
) -> Type[CheckpointHandler]:
"""Gets an entry from the registry."""
if handler_typestr not in self._registry:
raise ValueError(
raise KeyError(
f'Handler type string "{handler_typestr}" not found in the registry.'
)
return self._registry[handler_typestr]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def test_register_duplicate_handler_type(self):
def test_get_handler_type_not_found(self):
registry = HandlerTypeRegistry()
with self.assertRaisesRegex(
ValueError,
KeyError,
'Handler type string '
r'"(?:__main__|handler_type_registry_test)\.TestHandler"'
' not found in the registry.',
Expand Down

0 comments on commit f7bbe80

Please sign in to comment.