Handling error in search