Error Handling as Type Checking