Patterns

Optional error handling

Some functions take an error argument that direct the function to return None instead of raising an exception. New functions that do this should be split into multiple functions. If a function that raises (or allows) optional exceptions is annotated as returning an Optional value, every caller is expected to check the result, even though the result is not optional when error=False is passed.

Example 1: Function raises its own exceptions

Example 2: Function calls functions that raise optional exceptions