better exception handling when building the search response