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:
Pawan Verma
2020-06-27 11:24:33 +05:30
parent 7680c0d3ab
commit 1f97f89bae
22 changed files with 51 additions and 264 deletions
@@ -224,9 +224,6 @@ public class EbayHelper {
} catch (GenericEntityException gee) {
Debug.logError(gee, "Cannot get payment preferences for order #" + orderId, MODULE);
return false;
} catch (Exception e) {
Debug.logError(e, "Cannot get payment preferences for order #" + orderId, MODULE);
return false;
}
return true;
}
@@ -262,10 +259,7 @@ public class EbayHelper {
return false;
}
return true;
} catch (GenericEntityException e) {
Debug.logError(e, "Failed to create the payment for order " + orderId, MODULE);
return false;
} catch (GenericServiceException e) {
} catch (GenericEntityException | GenericServiceException e) {
Debug.logError(e, "Failed to create the payment for order " + orderId, MODULE);
return false;
}
@@ -327,8 +321,6 @@ public class EbayHelper {
}
} catch (GenericServiceException e) {
Debug.logError(e, "Failed to createPerson", MODULE);
} catch (Exception e) {
Debug.logError(e, "Failed to createPerson", MODULE);
}
return partyId;
}
@@ -1324,13 +1324,7 @@ public class EbayStore {
result.put("ebayStore", results.get("ebayStore"));
}
}
} catch (ApiException e) {
result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_ERROR);
result.put(ModelService.ERROR_MESSAGE, e.getMessage());
} catch (SdkSoapException e) {
result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_ERROR);
result.put(ModelService.ERROR_MESSAGE, e.getMessage());
} catch (SdkException e) {
} catch (ApiException | SdkException | SdkSoapException e) {
result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_ERROR);
result.put(ModelService.ERROR_MESSAGE, e.getMessage());
}
@@ -1651,10 +1645,8 @@ public class EbayStore {
result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_FAIL);
result.put(ModelService.ERROR_MESSAGE_LIST, ProductsExportToEbay.getproductExportFailureMessageList());
}
} catch (GenericEntityException|GenericServiceException ge) {
} catch (GenericEntityException | GenericServiceException ge) {
return ServiceUtil.returnError(ge.getMessage());
} catch (Exception e) {
return ServiceUtil.returnError(e.getMessage());
}
return result;
}
@@ -300,10 +300,7 @@ public class EbayStoreAutoPreferences {
}
request.setAttribute("_EVENT_MESSAGE_", "Setting Automated Positive Feedback for Buyers Success with site " + apiContext.getSite().value());
} catch (GenericEntityException e) {
request.setAttribute("_ERROR_MESSAGE_", e.getMessage());
return "error";
} catch (GenericServiceException e) {
} catch (GenericEntityException | GenericServiceException e) {
request.setAttribute("_ERROR_MESSAGE_", e.getMessage());
return "error";
}
@@ -523,10 +520,8 @@ public class EbayStoreAutoPreferences {
}
}
}
} catch (GenericEntityException|GenericServiceException ge) {
} catch (GenericEntityException | GenericServiceException ge) {
return ServiceUtil.returnError(ge.getMessage());
} catch (Exception e) {
return ServiceUtil.returnError(e.getMessage());
}
return ServiceUtil.returnSuccess();
}
@@ -598,10 +593,8 @@ public class EbayStoreAutoPreferences {
}
}
}
} catch (GenericEntityException|GenericServiceException ge) {
} catch (GenericEntityException | GenericServiceException ge) {
return ServiceUtil.returnError(ge.getMessage());
} catch (Exception e) {
return ServiceUtil.returnError(e.getMessage());
}
return ServiceUtil.returnSuccess();
}
@@ -673,10 +666,8 @@ public class EbayStoreAutoPreferences {
}
}
}
} catch (GenericEntityException|GenericServiceException ge) {
} catch (GenericEntityException | GenericServiceException ge) {
return ServiceUtil.returnError(ge.getMessage());
} catch (Exception e) {
return ServiceUtil.returnError(e.getMessage());
}
return ServiceUtil.returnSuccess();
}
@@ -908,9 +899,7 @@ public class EbayStoreAutoPreferences {
}
}
result = ServiceUtil.returnSuccess();
} catch (GenericEntityException e) {
result = ServiceUtil.returnError(e.getMessage());
} catch (GenericServiceException e) {
} catch (GenericEntityException | GenericServiceException e) {
result = ServiceUtil.returnError(e.getMessage());
} catch (Exception e) {
return ServiceUtil.returnError(e.getMessage());
@@ -1129,11 +1118,7 @@ public class EbayStoreAutoPreferences {
EbayStoreHelper.createErrorLogMessage(userLogin, dctx.getDispatcher(), context.get("productStoreId").toString(), resp.getAck().toString(), "Get selling manager inventory : autoBlockItemsOutOfStock", resp.getErrors(0).getLongMessage());
}
result = ServiceUtil.returnSuccess();
} catch (ApiException e) {
e.printStackTrace();
} catch (SdkSoapException e) {
e.printStackTrace();
} catch (SdkException e) {
} catch (ApiException | SdkException | SdkSoapException e) {
e.printStackTrace();
}
}
@@ -1183,10 +1168,8 @@ public class EbayStoreAutoPreferences {
}
}
}
} catch (GenericEntityException|GenericServiceException ge) {
} catch (GenericEntityException | GenericServiceException ge) {
return ServiceUtil.returnError(ge.getMessage());
} catch (Exception e) {
return ServiceUtil.returnError(e.getMessage());
}
return ServiceUtil.returnSuccess();
}
@@ -332,17 +332,8 @@ public class EbayStoreHelper {
runtimeData.set("runtimeInfo", XmlSerializer.serialize(infoData));
runtimeData.store();
}
} catch (GenericEntityException e) {
return ServiceUtil.returnError(e.getMessage());
} catch (GenericServiceException e) {
return ServiceUtil.returnError(e.getMessage());
} catch (SerializeException e) {
return ServiceUtil.returnError(e.getMessage());
} catch (IOException e) {
return ServiceUtil.returnError(e.getMessage());
}catch (RecurrenceInfoException e) {
return ServiceUtil.returnError(e.getMessage());
} catch (GenericConfigException e) {
} catch (GenericEntityException | GenericConfigException | RecurrenceInfoException | IOException | SerializeException
| GenericServiceException e) {
return ServiceUtil.returnError(e.getMessage());
}
return result;
@@ -369,9 +360,7 @@ public class EbayStoreHelper {
return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result));
}
}
} catch (GenericEntityException e) {
return ServiceUtil.returnError(e.getMessage());
} catch (GenericServiceException e) {
} catch (GenericEntityException | GenericServiceException e) {
return ServiceUtil.returnError(e.getMessage());
}
return result;
@@ -466,9 +455,7 @@ public class EbayStoreHelper {
}
}
result = ServiceUtil.returnSuccess();
} catch (GenericEntityException e) {
return ServiceUtil.returnError(e.getMessage());
} catch (GenericServiceException e) {
} catch (GenericEntityException | GenericServiceException e) {
return ServiceUtil.returnError(e.getMessage());
}
return result;
@@ -500,9 +487,7 @@ public class EbayStoreHelper {
}
}
}
} catch (GenericEntityException e) {
return ServiceUtil.returnError(e.getMessage());
} catch (GenericServiceException e) {
} catch (GenericEntityException | GenericServiceException e) {
return ServiceUtil.returnError(e.getMessage());
}
return ServiceUtil.returnSuccess();
@@ -709,8 +694,6 @@ public class EbayStoreHelper {
}
} catch (GenericEntityException gee) {
return ServiceUtil.returnError(gee.getMessage());
} catch (Exception e) {
return ServiceUtil.returnError(e.getMessage());
}
return ServiceUtil.returnSuccess();
}
@@ -121,11 +121,7 @@ public class EbayStoreInventoryServices {
result = ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "EbayStoreInventoryFolderIdUpdatedFailed", locale));
}
}
}catch (ApiException e) {
result = ServiceUtil.returnFailure(e.getMessage());
} catch (SdkSoapException e) {
result = ServiceUtil.returnFailure(e.getMessage());
} catch (SdkException e) {
} catch (ApiException | SdkException | SdkSoapException e) {
result = ServiceUtil.returnFailure(e.getMessage());
} catch (GenericEntityException e) {
result = ServiceUtil.returnFailure(e.getMessage());
@@ -172,11 +168,7 @@ public class EbayStoreInventoryServices {
Debug.logError("Fail to create inventory product ".concat(productId).concat("in productStore ").concat(context.get("productStoreId").toString()).concat(" message from ebay : ").concat(productResp.getMessage()), MODULE);
}
}
} catch (ApiException e) {
Debug.logError(e.getMessage(), MODULE);
} catch (SdkSoapException e) {
Debug.logError(e.getMessage(), MODULE);
} catch (SdkException e) {
} catch (ApiException | SdkException | SdkSoapException e) {
Debug.logError(e.getMessage(), MODULE);
} catch (GenericEntityException e) {
Debug.logError(e.getMessage(), MODULE);
@@ -228,11 +220,7 @@ public class EbayStoreInventoryServices {
Debug.logError("Fail to update inventory product ".concat(productId).concat("in productStore ").concat(context.get("productStoreId").toString()).concat(" message from ebay : ").concat(resp.getMessage()), MODULE);
}
}
} catch (ApiException e) {
Debug.logError(e.getMessage(), MODULE);
} catch (SdkSoapException e) {
Debug.logError(e.getMessage(), MODULE);
} catch (SdkException e) {
} catch (ApiException | SdkException | SdkSoapException e) {
Debug.logError(e.getMessage(), MODULE);
} catch (GenericEntityException e) {
Debug.logError(e.getMessage(), MODULE);
@@ -275,11 +263,7 @@ public class EbayStoreInventoryServices {
}
result = ServiceUtil.returnSuccess(UtilProperties.getMessage(RESOURCE, "EbayStoreInventoryFolderIdLoaded", UtilMisc.toMap("folderId", folderId), locale));
}
} catch (ApiException e) {
result = ServiceUtil.returnFailure(e.getMessage());
} catch (SdkSoapException e) {
result = ServiceUtil.returnFailure(e.getMessage());
} catch (SdkException e) {
} catch (ApiException | SdkException | SdkSoapException e) {
result = ServiceUtil.returnFailure(e.getMessage());
}
if (result.get("responseMessage") != null && "fail".equals(result.get("responseMessage"))) folderId = null;
@@ -310,11 +294,7 @@ public class EbayStoreInventoryServices {
return folderId;
}
}
} catch (ApiException e) {
Debug.logError(e.getMessage(), MODULE);
} catch (SdkSoapException e) {
Debug.logError(e.getMessage(), MODULE);
} catch (SdkException e) {
} catch (ApiException | SdkException | SdkSoapException e) {
Debug.logError(e.getMessage(), MODULE);
}
return folderId;
@@ -364,11 +344,7 @@ public class EbayStoreInventoryServices {
Debug.logError("The problem with get manage inventory detail from ebay site.", MODULE);
}
}
} catch (ApiException e) {
result = ServiceUtil.returnFailure(e.getMessage());
} catch (SdkSoapException e) {
result = ServiceUtil.returnFailure(e.getMessage());
} catch (SdkException e) {
} catch (ApiException | SdkException | SdkSoapException e) {
result = ServiceUtil.returnFailure(e.getMessage());
} catch (GenericEntityException e) {
result = ServiceUtil.returnFailure(e.getMessage());
@@ -398,9 +374,7 @@ public class EbayStoreInventoryServices {
}
}
}
} catch (GenericEntityException e) {
result = ServiceUtil.returnFailure(e.getMessage());
} catch (GenericServiceException e) {
} catch (GenericEntityException | GenericServiceException e) {
result = ServiceUtil.returnFailure(e.getMessage());
}
result = ServiceUtil.returnSuccess();
@@ -122,13 +122,7 @@ public class EbayStoreOptions {
EbayStoreHelper.createErrorLogMessage(userLogin, dispatcher, paramMap.get("productStoreId").toString(), resp.getAck().toString(), "GetStoreOptionsCall : retrieveThemeColorSchemeByThemeId", resp.getErrors(0).getLongMessage());
}
}
} catch (ApiException e) {
e.printStackTrace();
return "error";
} catch (SdkSoapException e) {
e.printStackTrace();
return "error";
} catch (SdkException e) {
} catch (ApiException | SdkException | SdkSoapException e) {
e.printStackTrace();
return "error";
}
@@ -191,16 +185,12 @@ public class EbayStoreOptions {
}
}
}
} catch (GenericServiceException e) {
Debug.logError(e.getMessage(), MODULE);
} catch (EventHandlerException e) {
Debug.logError(e.getMessage(), MODULE);
} catch (ApiException e) {
Debug.logError(e.getMessage(), MODULE);
} catch (SdkException e) {
Debug.logError(e.getMessage(), MODULE);
} catch (Exception e) {
Debug.logError(e.getMessage(), MODULE);
} catch (ApiException | SdkException e) {
Debug.logError(e.getMessage(), MODULE);
}
return "success";
}
@@ -247,16 +237,12 @@ public class EbayStoreOptions {
}
}
}
} catch (GenericServiceException e) {
Debug.logError(e.getMessage(), MODULE);
} catch (EventHandlerException e) {
Debug.logError(e.getMessage(), MODULE);
} catch (ApiException e) {
Debug.logError(e.getMessage(), MODULE);
} catch (SdkException e) {
Debug.logError(e.getMessage(), MODULE);
} catch (Exception e) {
Debug.logError(e.getMessage(), MODULE);
} catch (ApiException | SdkException e) {
Debug.logError(e.getMessage(), MODULE);
}
return "success";
}
@@ -181,9 +181,7 @@ public class JanrainHelper {
throw new RuntimeException("Unexpected URL error", e);
} catch (IOException e) {
throw new RuntimeException("Unexpected IO error", e);
} catch (ParserConfigurationException e) {
throw new RuntimeException("Unexpected XML error", e);
} catch (SAXException e) {
} catch (ParserConfigurationException | SAXException e) {
throw new RuntimeException("Unexpected XML error", e);
}
}
@@ -150,7 +150,6 @@ public final class OFBizCasAuthenticationHandler extends AbstractOFBizAuthentica
String logoutUri = UtilXml.childElementValue(rootElement, "CasLogoutUri", "/logout");
try {
response.sendRedirect(casUrl + logoutUri);
} catch (UnsupportedEncodingException e) {
} catch (IOException e) {
}
return "success";
@@ -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();
@@ -202,20 +202,11 @@ public class GitHubEvents {
request.setAttribute("_ERROR_MESSAGE_", errMsg);
return "error";
}
} catch (UnsupportedEncodingException e) {
} catch (URISyntaxException | ConversionException | IOException e) {
request.setAttribute("_ERROR_MESSAGE_", e.toString());
return "error";
} catch (IOException e) {
request.setAttribute("_ERROR_MESSAGE_", e.toString());
return "error";
} catch (ConversionException e) {
request.setAttribute("_ERROR_MESSAGE_", e.toString());
return "error";
} catch (URISyntaxException e) {
request.setAttribute("_ERROR_MESSAGE_", e.toString());
return "error";
}
}
// Get User Profile
HttpGet getMethod = new HttpGet(ApiEndpoint + UserApiUri);
Map<String, Object> userInfo = null;
@@ -291,11 +282,7 @@ public class GitHubEvents {
userLogin.store();
request.setAttribute("USERNAME", userLogin.getString("userLoginId"));
request.setAttribute("PASSWORD", autoPassword);
} catch (GenericEntityException e) {
Debug.logError(e.getMessage(), MODULE);
request.setAttribute("_ERROR_MESSAGE_", e.toString());
return "error";
} catch (AuthenticatorException e) {
} catch (GenericEntityException | AuthenticatorException e) {
Debug.logError(e.getMessage(), MODULE);
request.setAttribute("_ERROR_MESSAGE_", e.toString());
return "error";
@@ -200,35 +200,17 @@ public class LinkedInEvents {
request.setAttribute("_ERROR_MESSAGE_", errMsg);
return "error";
}
} catch (UnsupportedEncodingException e) {
} catch (URISyntaxException | ConversionException | IOException e) {
request.setAttribute("_ERROR_MESSAGE_", e.toString());
return "error";
} catch (IOException e) {
request.setAttribute("_ERROR_MESSAGE_", e.toString());
return "error";
} catch (ConversionException e) {
request.setAttribute("_ERROR_MESSAGE_", e.toString());
return "error";
} catch (URISyntaxException e) {
request.setAttribute("_ERROR_MESSAGE_", e.toString());
return "error";
}
}
// Get User Profile
HttpGet getMethod = new HttpGet(TokenEndpoint + UserApiUri + "?oauth2_access_token=" + accessToken);
Document userInfo = null;
try {
userInfo = LinkedInAuthenticator.getUserInfo(getMethod, UtilHttp.getLocale(request));
} catch (IOException e) {
request.setAttribute("_ERROR_MESSAGE_", e.toString());
return "error";
} catch (AuthenticatorException e) {
request.setAttribute("_ERROR_MESSAGE_", e.toString());
return "error";
} catch (SAXException e) {
request.setAttribute("_ERROR_MESSAGE_", e.toString());
return "error";
} catch (ParserConfigurationException e) {
} catch (IOException | ParserConfigurationException | SAXException | AuthenticatorException e) {
request.setAttribute("_ERROR_MESSAGE_", e.toString());
return "error";
} finally {
@@ -298,11 +280,7 @@ public class LinkedInEvents {
userLogin.store();
request.setAttribute("USERNAME", userLogin.getString("userLoginId"));
request.setAttribute("PASSWORD", autoPassword);
} catch (GenericEntityException e) {
Debug.logError(e.getMessage(), MODULE);
request.setAttribute("_ERROR_MESSAGE_", e.toString());
return "error";
} catch (AuthenticatorException e) {
} catch (GenericEntityException | AuthenticatorException e) {
Debug.logError(e.getMessage(), MODULE);
request.setAttribute("_ERROR_MESSAGE_", e.toString());
return "error";
@@ -114,9 +114,7 @@ public class GitHubAuthenticator implements Authenticator {
user = GitHubAuthenticator.getUserInfo(getMethod, accessToken, tokenType, Locale.getDefault());
}
}
} catch (GenericEntityException e) {
throw new AuthenticatorException(e.getMessage(), e);
} catch (AuthenticatorException e) {
} catch (GenericEntityException | AuthenticatorException e) {
throw new AuthenticatorException(e.getMessage(), e);
} finally {
if (getMethod != null) {
@@ -222,9 +220,7 @@ public class GitHubAuthenticator implements Authenticator {
user = getUserInfo(getMethod, accessToken, tokenType, Locale.getDefault());
}
}
} catch (GenericEntityException e) {
throw new AuthenticatorException(e.getMessage(), e);
} catch (AuthenticatorException e) {
} catch (GenericEntityException | AuthenticatorException e) {
throw new AuthenticatorException(e.getMessage(), e);
}
return user;
@@ -114,16 +114,10 @@ public class LinkedInAuthenticator implements Authenticator {
user = LinkedInAuthenticator.getUserInfo(getMethod, Locale.getDefault());
}
}
} catch (GenericEntityException e) {
throw new AuthenticatorException(e.getMessage(), e);
} catch (IOException e) {
throw new AuthenticatorException(e.getMessage(), e);
} catch (AuthenticatorException e) {
} catch (GenericEntityException | ParserConfigurationException | AuthenticatorException | IOException e) {
throw new AuthenticatorException(e.getMessage(), e);
} catch (SAXException e) {
throw new AuthenticatorException(e.getMessage(), e);
} catch (ParserConfigurationException e) {
throw new AuthenticatorException(e.getMessage(), e);
} finally {
if (getMethod != null) {
getMethod.releaseConnection();
@@ -228,16 +222,10 @@ public class LinkedInAuthenticator implements Authenticator {
user = getUserInfo(getMethod, Locale.getDefault());
}
}
} catch (GenericEntityException e) {
throw new AuthenticatorException(e.getMessage(), e);
} catch (IOException e) {
throw new AuthenticatorException(e.getMessage(), e);
} catch (AuthenticatorException e) {
} catch (GenericEntityException | ParserConfigurationException | AuthenticatorException | IOException e) {
throw new AuthenticatorException(e.getMessage(), e);
} catch (SAXException e) {
throw new AuthenticatorException(e.getMessage(), e);
} catch (ParserConfigurationException e) {
throw new AuthenticatorException(e.getMessage(), e);
} finally {
if (getMethod != null) {
getMethod.releaseConnection();
@@ -860,9 +860,7 @@ public class HtmlReport extends AbstractReport {
Object o = null;
try {
o = m.invoke(this, new Object[0]);
} catch (InvocationTargetException ite) {
// can usually be ignored
} catch (IllegalAccessException eae) {
} catch (InvocationTargetException | IllegalAccessException ite) {
// can usually be ignored
}
if (o != null) {
@@ -266,9 +266,6 @@ public abstract class AbstractPricatParser implements InterfacePricatParser {
fos.flush();
fos.close();
workbook.close();
} catch (FileNotFoundException e) {
report.println(e);
Debug.logError(e, MODULE);
} catch (IOException e) {
report.println(e);
Debug.logError(e, MODULE);
@@ -617,10 +614,7 @@ public abstract class AbstractPricatParser implements InterfacePricatParser {
GenericValue historyValue = null;
try {
historyValue = EntityQuery.use(delegator).from("ExcelImportHistory").where("userLoginId", userLoginId, "sequenceNum", Long.valueOf(sequenceNum)).queryOne();
} catch (NumberFormatException e) {
Debug.logError(e.getMessage(), MODULE);
return false;
} catch (GenericEntityException e) {
} catch (NumberFormatException | GenericEntityException e) {
Debug.logError(e.getMessage(), MODULE);
return false;
}
@@ -74,9 +74,6 @@ public class PricatEvents {
Path file = Paths.get(path + fileName);
byte[] bytes = Files.readAllBytes(file);
UtilHttp.streamContentToBrowser(response, bytes, "application/octet-stream", URLEncoder.encode(fileName, "UTF-8"));
} catch (MalformedURLException e) {
Debug.logError(e.getMessage(), MODULE);
return "error";
} catch (IOException e) {
Debug.logError(e.getMessage(), MODULE);
return "error";
@@ -116,9 +113,6 @@ public class PricatEvents {
byte[] bytes = Files.readAllBytes(path);
path = Paths.get(originalPricatFileName);
UtilHttp.streamContentToBrowser(response, bytes, "application/octet-stream", URLEncoder.encode(path.getName(path.getNameCount() - 1).toString(), "UTF-8"));
} catch (MalformedURLException e) {
Debug.logError(e.getMessage(), MODULE);
return "error";
} catch (IOException e) {
Debug.logError(e.getMessage(), MODULE);
return "error";
@@ -150,10 +144,7 @@ public class PricatEvents {
GenericValue historyValue = null;
try {
historyValue = EntityQuery.use(delegator).from("ExcelImportHistory").where("userLoginId", userLoginId, "sequenceNum", Long.valueOf(sequenceNum)).queryOne();
} catch (NumberFormatException e) {
Debug.logError(e.getMessage(), MODULE);
return "error";
} catch (GenericEntityException e) {
} catch (NumberFormatException | GenericEntityException e) {
Debug.logError(e.getMessage(), MODULE);
return "error";
}
@@ -172,9 +163,6 @@ public class PricatEvents {
byte[] bytes = Files.readAllBytes(path);
UtilHttp.streamContentToBrowser(response, bytes, "application/octet-stream", URLEncoder.encode(fileName, "UTF-8"));
}
} catch (MalformedURLException e) {
Debug.logError(e.getMessage(), MODULE);
return "error";
} catch (IOException e) {
Debug.logError(e.getMessage(), MODULE);
return "error";
@@ -69,9 +69,6 @@ public class SamplePricatEvents extends PricatEvents {
Path file = Paths.get(path + fileName);
byte[] bytes = Files.readAllBytes(file);
UtilHttp.streamContentToBrowser(response, bytes, "application/octet-stream", URLEncoder.encode(fileName, "UTF-8"));
} catch (MalformedURLException e) {
Debug.logError(e.getMessage(), MODULE);
return "error";
} catch (IOException e) {
Debug.logError(e.getMessage(), MODULE);
return "error";
@@ -239,15 +239,9 @@ public class ScrumServices {
}
}
}
} catch (IOException e) {
} catch (IOException | GenericServiceException | GenericEntityException e) {
e.printStackTrace();
return ServiceUtil.returnError(e.getMessage());
} catch (GenericEntityException entityEx) {
entityEx.printStackTrace();
return ServiceUtil.returnError(entityEx.getMessage());
} catch (GenericServiceException serviceEx) {
serviceEx.printStackTrace();
return ServiceUtil.returnError(serviceEx.getMessage());
}
return result;
@@ -230,8 +230,6 @@ public final class ProductUtil {
}
}
}
} catch (GenericEntityException e) {
Debug.logError(e, e.getMessage(), MODULE);
} catch (Exception e) {
Debug.logError(e, e.getMessage(), MODULE);
}
@@ -96,19 +96,10 @@ public abstract class SolrProductSearch {
} else {
result = ServiceUtil.returnSuccess();
}
}
catch (GenericEntityException gee) {
Debug.logError(gee, gee.getMessage(), MODULE);
result = ServiceUtil.returnError(gee.toString());
}
catch (GenericServiceException gse) {
} catch (GenericEntityException | GenericServiceException gse) {
Debug.logError(gse, gse.getMessage(), MODULE);
result = ServiceUtil.returnError(gse.toString());
}
catch (Exception e) {
Debug.logError(e, e.getMessage(), MODULE);
result = ServiceUtil.returnError(e.toString());
}
} else {
final String statusMsg = "Solr ECA indexing disabled; skipping indexing for productId '" + productId + "'";
if (Debug.verboseOn()) Debug.logVerbose("Solr: addToSolr: " + statusMsg, MODULE);
@@ -707,8 +698,7 @@ public abstract class SolrProductSearch {
final String statusMsg = UtilProperties.getMessage(RESOURCE, "SolrClearedSolrIndexAndReindexedDocuments", UtilMisc.toMap("numDocs", numDocs), locale);
result = ServiceUtil.returnSuccess(statusMsg);
}
}
catch (MalformedURLException e) {
} catch (IOException | GenericServiceException e) {
Debug.logError(e, e.getMessage(), MODULE);
result = ServiceUtil.returnError(e.toString());
}
@@ -726,28 +716,7 @@ public abstract class SolrProductSearch {
Debug.logError(e, e.getMessage(), MODULE);
result = ServiceUtil.returnError(e.toString());
}
}
catch (IOException e) {
Debug.logError(e, e.getMessage(), MODULE);
result = ServiceUtil.returnError(e.toString());
}
catch (ServiceAuthException e) {
Debug.logError(e, e.getMessage(), MODULE);
result = ServiceUtil.returnError(e.toString());
}
catch (ServiceValidationException e) {
Debug.logError(e, e.getMessage(), MODULE);
result = ServiceUtil.returnError(e.toString());
}
catch (GenericServiceException e) {
Debug.logError(e, e.getMessage(), MODULE);
result = ServiceUtil.returnError(e.toString());
}
catch (Exception e) {
Debug.logError(e, e.getMessage(), MODULE);
result = ServiceUtil.returnError(e.toString());
}
finally {
} finally {
if (client != null) {
try {
client.close();