Python errors and exceptions
Handle invalid entries, missing records, and interrupted work. Follow each failure from the input that triggers it to a response the user can act on.
Input and validation
- Length check before slicingRead the depot prefix on a damaged label
- None guardPrint a label when the phone number is missing
- ValueErrorReject a mistyped order quantity
- date.fromisoformat and ValueErrorCheck a delivery date entered on a form
- isinstanceCheck the type of an imported fare
- re.errorValidate a saved product search
State and collections
- IndexErrorFind a seat after the coach changes
- ZeroDivisionErrorSplit an equipment fee across a class
- deque.popleft and IndexErrorCall the next person at the clinic
- tuple and list copyAdd a stop to a published bus route
Files and streams
- FileExistsErrorSave a report without replacing the first copy
- FileNotFoundErrorRecover when a receipt is missing
- ValueError on a closed streamRead from a finished receipt import
- struct.errorRead a stock count from a short record
Jobs and runtime
- CancelledErrorCollect a cancelled print job
- Future.result timeoutLimit the wait for a shipping quote
- ModuleNotFoundErrorLoad an optional invoice exporter