Functional error handling