Fix error handling: Return custom errors.