chromatictools.functional module

Utilities for handling and wrapping functions

chromatictools.functional.recast_exception(type_a: Union[Type[Exception], Tuple[Type[Exception], ...]], type_b: Type[Exception])

Function decorator for wrapping a function: when that function would have raised an Exception in type_a, now it will return a type_b exception

Parameters
  • type_a (type(s) of exception) – A subclass of Exception or a tuple of subclasses. These exceptions will be recast

  • type_b (type of exception) – New type for recast exceptions

Returns

Function decorator