Kotlin 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
- DateTimeParseExceptionCheck a delivery date entered on a form
- PatternSyntaxExceptionValidate a saved product search
- Safe call and ElvisPrint a label when the phone number is missing
- Safe cast with as?Check the type of an imported fare
- requireReject an empty ticket order
- toIntOrNullReject a mistyped order quantity
State and collections
- ArithmeticExceptionSplit an equipment fee across a class
- ArrayDeque.removeFirstOrNullCall the next person at the clinic
- ConcurrentModificationExceptionRemove an expired pass during inspection
- List.plusAdd a stop to a published bus route
- check and IllegalStateExceptionAdd an item after checkout closes
- getOrNullFind a seat after the coach changes
Files and streams
- EOFExceptionRead a stock count from a short record
- FileAlreadyExistsExceptionSave a report without replacing the first copy
- IOException on a closed readerRead from a finished receipt import
- NoSuchFileExceptionRecover when a receipt is missing
Jobs and runtime
- CancellationExceptionCollect a cancelled print job
- ClassNotFoundExceptionLoad an optional invoice exporter
- ExecutionExceptionFind the reason a background import failed
- InterruptedExceptionStop waiting when a shift ends
- TimeoutExceptionLimit the wait for a shipping quote