[ILibrary / LazyLibrary] raise a LibraryError instead of KeyError
This commit is contained in:
parent
f0a4b08a31
commit
ce7bf5ce70
2 changed files with 13 additions and 0 deletions
|
|
@ -826,6 +826,8 @@ class ILibrary(ILibraryView, MutableMapping[str, 'Pattern'], metaclass=ABCMeta):
|
|||
Returns:
|
||||
self
|
||||
"""
|
||||
if old_name not in self:
|
||||
raise LibraryError(f'"{old_name}" does not exist in the library.')
|
||||
self[new_name] = self[old_name]
|
||||
del self[old_name]
|
||||
if move_references:
|
||||
|
|
@ -1479,6 +1481,8 @@ class LazyLibrary(ILibrary):
|
|||
Returns:
|
||||
self
|
||||
"""
|
||||
if old_name not in self.mapping:
|
||||
raise LibraryError(f'"{old_name}" does not exist in the library.')
|
||||
self[new_name] = self.mapping[old_name] # copy over function
|
||||
if old_name in self.cache:
|
||||
self.cache[new_name] = self.cache[old_name]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue