Source:
<code>public RestLiResponseData<BatchFinderResponseEnvelope> buildRestLiResponseData(Request request, RoutingResult routingResult, Object object, Map<String, String> headers, List<HttpCookie> cookies) { BatchFinderResult<RecordTemplate, RecordTemplate, RecordTemplate> result = (BatchFinderResult<RecordTemplate, RecordTemplate, RecordTemplate>) object; DataList criteriaParams = getCriteriaParameters(routingResult); List<BatchFinderEntry> collectionResponse = new ArrayList<>(criteriaParams.size()); final ResourceContextImpl resourceContext = (ResourceContextImpl) routingResult.getContext(); TimingContextUtil.beginTiming(routingResult.getContext().getRawRequestContext(), FrameworkTimingKeys.SERVER_RESPONSE_RESTLI_PROJECTION_APPLY.key()); <START> try <END> { for (Object criteriaParam : criteriaParams.values()) { RecordTemplate criteria = new AnyRecord((DataMap) criteriaParam); BatchFinderEntry entry; if (result.getResults().containsKey(criteria)) { CollectionResult<RecordTemplate, RecordTemplate> cr = result.getResult(criteria); List<AnyRecord> elements = buildElements(cr, resourceContext); final CollectionMetadata projectedPaging = buildPaginationMetaData(routingResult, criteria, resourceContext, request, cr); final AnyRecord projectedCustomMetadata = buildMetaData(cr, resourceContext); entry = new BatchFinderEntry(elements, projectedPaging, projectedCustomMetadata); } else if (result.getErrors().containsKey(criteria)) { entry = new BatchFinderEntry(result.getErrors().get(criteria)); } else { entry = new BatchFinderEntry( new RestLiServiceException(S_404_NOT_FOUND, "The server didn't find a representation for this criteria")); } collectionResponse.add(entry); } TimingContextUtil.endTiming(routingResult.getContext().getRawRequestContext(), FrameworkTimingKeys.SERVER_RESPONSE_RESTLI_PROJECTION_APPLY.key()); return new RestLiResponseDataImpl<>(new BatchFinderResponseEnvelope(HttpStatus.S_200_OK, collectionResponse), headers, cookies); } catch (CloneNotSupportedException exception) { throw new RestLiServiceException(S_500_INTERNAL_SERVER_ERROR, "Batch finder response builder failed when rebuild projection URI"); } }</code><technical_language>Wrapping logic in a try-catch is excessive harder understand. resulting service error error Rest.li unable build criteria URI, sense put this try-catch service error #buildCriteriaURI</technical_language>

Target:
public RestLiResponseData<BatchFinderResponseEnvelope> buildRestLiResponseData(Request request, RoutingResult routingResult, Object object, Map<String, String> headers, List<HttpCookie> cookies) { BatchFinderResult<RecordTemplate, RecordTemplate, RecordTemplate> result = (BatchFinderResult<RecordTemplate, RecordTemplate, RecordTemplate>) object; DataList criteriaParams = getCriteriaParameters(routingResult); List<BatchFinderEntry> collectionResponse = new ArrayList<>(criteriaParams.size()); final ResourceContextImpl resourceContext = (ResourceContextImpl) routingResult.getContext(); TimingContextUtil.beginTiming(routingResult.getContext().getRawRequestContext(), FrameworkTimingKeys.SERVER_RESPONSE_RESTLI_PROJECTION_APPLY.key()); for (Object criteriaParam : criteriaParams.values()) { RecordTemplate criteria = new AnyRecord((DataMap) criteriaParam); BatchFinderEntry entry; if (result.getResults().containsKey(criteria)) { CollectionResult<RecordTemplate, RecordTemplate> cr = result.getResult(criteria); List<AnyRecord> elements = buildElements(cr, resourceContext); final CollectionMetadata projectedPaging = buildPaginationMetaData(routingResult, criteria, resourceContext, request, cr); final AnyRecord projectedCustomMetadata = buildMetaData(cr, resourceContext); entry = new BatchFinderEntry(elements, projectedPaging, projectedCustomMetadata); } else if (result.getErrors().containsKey(criteria)) { entry = new BatchFinderEntry(result.getErrors().get(criteria)); } else { entry = new BatchFinderEntry( new RestLiServiceException(S_404_NOT_FOUND, "The server didn't find a representation for this criteria")); } collectionResponse.add(entry); } TimingContextUtil.endTiming(routingResult.getContext().getRawRequestContext(), FrameworkTimingKeys.SERVER_RESPONSE_RESTLI_PROJECTION_APPLY.key()); return new RestLiResponseDataImpl<>(new BatchFinderResponseEnvelope(HttpStatus.S_200_OK, collectionResponse), headers, cookies); }