Improved: Merge identical catch blocks in single catch block(OFBIZ-11827)
In Java SE 7 and later, a single catch block can handle more than one type of exception. This feature can reduce code duplication and lessen the temptation to catch an overly broad exception. Thanks: Jacques for the review.
This commit is contained in:
@@ -129,12 +129,9 @@ public class ContentDocument implements LuceneDocument {
|
||||
String text;
|
||||
try {
|
||||
text = ContentWorker.renderContentAsText(dispatcher, contentId, null, locale, mimeTypeId, true);
|
||||
} catch (GeneralException e) {
|
||||
} catch (GeneralException | IOException e) {
|
||||
Debug.logError(e, MODULE);
|
||||
return false;
|
||||
} catch (IOException e2) {
|
||||
Debug.logError(e2, MODULE);
|
||||
return false;
|
||||
}
|
||||
if (UtilValidate.isNotEmpty(text)) {
|
||||
Field field = new TextField("content", text, Store.NO);
|
||||
|
||||
@@ -204,9 +204,7 @@ public class ProductDocument implements LuceneDocument {
|
||||
Map<String, Object> drContext = UtilMisc.<String, Object>toMap("product", product);
|
||||
String contentText = DataResourceWorker.renderDataResourceAsText(null, delegator, productContentAndInfo.getString("dataResourceId"), drContext, null, null, false);
|
||||
addTextField(doc, "content", contentText, false, "fullText", delegator);
|
||||
} catch (IOException e1) {
|
||||
Debug.logError(e1, "Error getting content text to index", MODULE);
|
||||
} catch (GeneralException e1) {
|
||||
} catch (IOException | GeneralException e1) {
|
||||
Debug.logError(e1, "Error getting content text to index", MODULE);
|
||||
}
|
||||
|
||||
|
||||
@@ -126,9 +126,7 @@ public class SearchServices {
|
||||
return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result));
|
||||
}
|
||||
}
|
||||
} catch (GenericEntityException e) {
|
||||
Debug.logError(e, MODULE);
|
||||
} catch (GenericServiceException e) {
|
||||
} catch (GenericEntityException | GenericServiceException e) {
|
||||
Debug.logError(e, MODULE);
|
||||
}
|
||||
return ServiceUtil.returnSuccess();
|
||||
|
||||
Reference in New Issue
Block a user