Add error handling around search