0% found this document useful (0 votes)
25 views40 pages

Java Exception Handling in Product Services

This document contains code snippets from various Java files that show how exceptions are handled within try-catch blocks. The snippets focus on logging errors and rethrowing exceptions in some cases.

Uploaded by

anshukan
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views40 pages

Java Exception Handling in Product Services

This document contains code snippets from various Java files that show how exceptions are handled within try-catch blocks. The snippets focus on logging errors and rethrowing exceptions in some cases.

Uploaded by

anshukan
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd

Class Line

[Link] 70

[Link] (3 matches) 50

103

106

[Link] 149

[Link] 60

[Link] 132

[Link] (2 matches) 85

96
[Link] (3 matches) 85

87

89

[Link] 122

[Link] (2 matches) 76

87

[Link] 84

[Link] 63

[Link] 105

[Link] (2 matches) 117


294
[Link] (2 matches)

85

166

[Link] 63

[Link] (6 matches) 363


454

665

923

1361

1425

[Link] 785

[Link] (2 matches) 244

341

[Link] 71

[Link] 146
Verification

SkuSwatchUtils
content Remark

catch (Exception e) {
return new
ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
} No issue

catch (IOException ioe) {


[Link]("Failed to parse media obejct
string '{}' to json node.", [Link](), ioe);
} changes done

catch (IOException ioe) {


[Link]("Failed to parse media array element string
'{}' to json node.",
[Link](), ioe);
} changes done

catch (IOException ioe) {


[Link]("Failed to parse media array element string
'{}' to json node.",
[Link](), ioe);
} catch (Exception e) {
[Link]("Failed to parse media array element string
'{}' to json node.",
arrayElementTextJsonNode, e);
} changes done

catch (IOException ex) {


[Link]("Exception while parsing the vendor
config node, exception message is :: {}",
[Link]());
} No issue

catch (IOException ioe) {


[Link]("Failed to parse json text '{}' to
JsonNode,", [Link](), ioe);
} changes done

catch (IOException ioe) {


[Link]("Failed to parse json text '{}' to
JsonNode,", [Link](), ioe);
} changes done

catch (IOException e) {
[Link]("ERROR occurred while adding
JsonNode to attributes map: {}" , e);
} changes done

catch (IOException e) {
[Link]("ERROR occurred while adding
JsonNode to attributes map: {}" , e);
} changes done
catch (JsonMappingException e) {
[Link]("JsonMappingException in
parsing cached data {}, key - {} and error {}", skuPriceRedisKey,
cachedSkuPriceData, [Link]());
} changes done

catch (JsonProcessingException e) {
[Link]("JsonProcessingException in
parsing cached data {}, key - {} and error {}", skuPriceRedisKey,
cachedSkuPriceData, e);
} changes done

catch (Exception e) {
[Link]("ReadPriceFromRedisProcessor
processJsonElement() : Exception occurred -", e); changes done

catch (IOException ioe) {


[Link]("Failed to parse attribute string '{}' to
json node.", jsonNode, ioe);
} changes done

catch (IOException e) {
[Link]("ERROR occurred while adding
JsonNode to attributes map: {}" , e);
} changes done

catch (IOException e) {
[Link]("ERROR occurred while adding
JsonNode to attributes map: {}" , e);
} changes done

catch (IOException ioe) {


[Link]("Failed to parse json text
'{}' to roll_up_type,", [Link](), ioe);
} changes done

catch (IOException ioe) {


[Link]("Failed to parse string to json node.",
[Link](), [Link](),
ioe);
} changes done

catch (ParseException e) {
[Link]("Error occured while parsing vdcOffsetDate
date in VdcOffsetDateOrphanProcessor");
} changes done

catch (Exception e) {
String msg =
[Link](BBBCoreRestConstants.REST_EXCEPTION_MESSA
GE, eomAtsUrl);
[Link](msg, e);
} changes done
catch (JSONException e) {
[Link]("An exception occured while constructing
EOM ATS payload :: ",e);
} changes done

catch (Exception ex) {


if([Link]() instanceof
CataloguePersonalizationInvalidServiceResponseException){
String msg = "";
if
([Link]().contains(BBBCatalogueConstants.ERR_INVALID_SKU_SE
RVICE_OR_VENDOR_SERVICE_RESPONSE)){
msg =
[Link]().substring([Link]().indexOf(BBBCatalogueConsta
nts.ERR_INVALID_SKU_SERVICE_OR_VENDOR_SERVICE_RESPONSE));
} else if
([Link]().contains("CataloguePersonalizationInvalidServiceRespo
nseException")){
msg =
[Link]().substring([Link]().lastIndexOf("CataloguePerso
nalizationInvalidServiceResponseException:")
+"CataloguePersonalizationInvalidServiceResponseException".length()
+1);
}
throw new
CataloguePersonalizationInvalidServiceResponseException([Link]());
}else{
throw new
CataloguePersonalizationGenericException("Exception occured while
fetching the output response", ex);
}
} No issue

catch (BaseFusionJsonParserException ex) {


[Link]([Link](), ex);
} changes done

catch (IOException ex) {


[Link]("Exception while parsing the vendor
config node.",
ex);
} changes done

catch (Exception e) {
[Link]("Product Detail GroupBy response
throwing::", e);

} changes done
catch (IOException e) {
[Link]("Exception while parsing the everliving node
for id(s)- {}", id,e);
} changes done

catch (IOException e) {
throw new
FusionJsonTreeDeserializeException("Failed to to parse json response for
child product details", e);
} No issue

catch (IOException e) {
throw new FusionJsonTreeDeserializeException("Failed to
to parse json response while fetching child products", e);
} No issue

catch (JSONException e) {
[Link]();
} changes done

catch (JSONException e) {
[Link]();
} changes done

catch (JSONException e) {
[Link]();
} changes done

catch(Exception e) {
[Link]("Error while extracting atrributes from
TOD node Exception is :: {} ", [Link]());
attributes = (LinkedHashMap<String, String>)
[Link]().get(BBBCatalogueConstants.ATTRIBUTES_JSON)
;
} No issue

catch(Exception e) {
[Link]("Error while extracting atrributes from
TOD node Exception is :: {} ", [Link]());
attributes = (LinkedHashMap<String, String>)
[Link](BBBCatalogueConstants.ATTRIBUTES_JSON);
} No issue

catch (Exception e) {
[Link]("ERROR occurred while getting Tooltip Data " +
[Link]());
} No issue

catch (IOException ioe) {


[Link]("Failed to parse json text '{}' to
skuSwatchAllJsonNode,", [Link](), ioe);
}
Failed to parse json text
Not found

Not found

Not found

Not found

Not found

Not found

Not found

Not found
Not found

Not found

Not found
Class Line

[Link] 70

[Link] (3 matches) 50

103

106

[Link] 149

[Link] 132

[Link] (2 matches) 85

96

[Link] 261

[Link] (3 matches) 85
87

89

[Link] 122

[Link] (2 matches) 76

87

[Link] 84

[Link] 63

[Link] 105

[Link] (2 matches) 61
87

[Link] (2 matches) 62

95

[Link] (3 matches) 261

291

509

[Link] (3 matches) 73

95
117

[Link] 103

[Link] (2 matches) 117

294

[Link] (3 matches) 105

156

207
[Link] (2 matches) 85

166

[Link] 63

[Link] (4 matches) 589

800
1058

1494

[Link] (6 matches) 305

407

584

952

955

2746
[Link] 786

[Link] (2 matches) 244

341

[Link] 71

[Link] 166

[Link] 321

[Link] 103

[Link] 146
content
catch (Exception e) {
return new
ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}

catch (IOException ioe) {


[Link]("Failed to parse media obejct
string '{}' to json node.", [Link](), ioe);
}

catch (IOException ioe) {


[Link]("Failed to parse media array element string '{}'
to json node.",
[Link](), ioe);
}

catch (Exception e) {
[Link]("Failed to parse media array element string '{}'
to json node.",
arrayElementTextJsonNode, e);
}

catch (IOException ex) {


[Link]("Exception while parsing the vendor
config node, exception message is :: {}",
[Link]());
}

catch (IOException ioe) {


[Link]("Failed to parse json text '{}' to
JsonNode,", [Link](), ioe);
}

catch (IOException e) {
[Link]("ERROR occurred while adding JsonNode to
attributes map: {}" , e);
}

catch (IOException e) {
[Link]("ERROR occurred while adding JsonNode to
attributes map: {}" , e);
}

catch (IOException e) {
[Link]("ERROR occurred while adding JsonNode to
attributes map: " + e);
}

catch (JsonMappingException e) {
[Link]("JsonMappingException in parsing
cached data {}, key - {} and error {}", skuPriceRedisKey, cachedSkuPriceData,
[Link]());
}
catch (JsonProcessingException e) {
[Link]("JsonProcessingException in
parsing cached data {}, key - {} and error {}", skuPriceRedisKey,
cachedSkuPriceData, e);
}

catch (Exception e) {
[Link]("ReadPriceFromRedisProcessor
processJsonElement() : Exception occurred -", e);
}

catch (IOException ioe) {


[Link]("Failed to parse attribute string '{}' to json
node.", jsonNode, ioe);
}

catch (IOException e) {
[Link]("ERROR occurred while adding JsonNode to
attributes map: {}" , e);
}

catch (IOException e) {
[Link]("ERROR occurred while adding JsonNode to
attributes map: {}" , e);
}

catch (IOException ioe) {


[Link]("Failed to parse json text '{}'
to roll_up_type,", [Link](), ioe);
}

catch (IOException ioe) {


[Link]("Failed to parse string to json node.",
[Link](), [Link](),
ioe);
}

catch (ParseException e) {
[Link]("Error occured while parsing vdcOffsetDate date
in VdcOffsetDateOrphanProcessor");
}

catch (UnknownHostException e) {
[Link] += [Link]();
[Link]("PDP : CatalogV2
ExperienceDataKafkaMessageListenerCatalog : Setting
experienceListenerGroupId with UUID : {}", experienceListenerGroupId);
}
catch (Exception ex) {
String msg = [Link]("An exception occured
while consuming the kafka message payload for experience data {0}",
payload);
[Link](msg, ex);
}

catch (UnknownHostException e) {
[Link] += [Link]();
[Link]("PDP : CatalogV2
LabelDataKafkaMessageListenerCatalog : Setting lableListenerGroupId with
UUID : {}", lableListenerGroupId);
}

catch (Exception ex) {


String msg = [Link]("PDP : An exception
occured while consuming the kafka message payload for Label data {0}",
payload);
[Link](msg, ex);
}

catch (Exception e) {
String msg =
[Link](BBBCoreRestConstants.REST_EXCEPTION_MESSAGE
, groupbyOOSProductEndpoint);
[Link](msg, [Link]());
}

catch (IOException e) {

[Link](BBBCatalogueConstants.JSON_PARSING_EXCEP_MSG, e);
}

catch (Exception e) {
String msg =
[Link](BBBCoreRestConstants.REST_EXCEPTION_MESSAGE
, beyondPlusEligibleURL);
[Link](msg, [Link]());
}

catch (IOException e) {

[Link](BBBCatalogueConstants.JSON_PARSING_EXCEP_MSG, e);
}

catch (IOException e) {

[Link](BBBCatalogueConstants.JSON_PARSING_EXCEP_MSG, e);
}
catch (IOException e) {

[Link](BBBCatalogueConstants.JSON_PARSING_EXCEP_MSG, e);
}

catch (IOException e) {
throw new CacheAssemblerJsonParserException("Error
occured while converting String to JsonNode.", e);
}

catch (Exception e) {
String msg =
[Link](BBBCoreRestConstants.REST_EXCEPTION_MESSAGE
, eomAtsUrl);
[Link](msg, e);
}

catch (JSONException e) {
[Link]("An exception occured while constructing EOM
ATS payload :: ",e);
}

catch (IOException e) {
String msg = [Link](LOG_ERROR_MSG,
[Link]());
[Link](msg, e);
}

catch (IOException e) {
String msg = [Link](LOG_ERROR_MSG,
[Link]());
[Link](msg, e);
}

catch (IOException e) {
String msg = [Link](LOG_ERROR_MSG,
[Link]());
[Link](msg, e);
}
catch (Exception ex) {
if([Link]() instanceof
CataloguePersonalizationInvalidServiceResponseException){
String msg = "";
if
([Link]().contains(BBBCatalogueConstants.ERR_INVALID_SKU_SERV
ICE_OR_VENDOR_SERVICE_RESPONSE)){
msg =
[Link]().substring([Link]().indexOf(BBBCatalogueConstants
.ERR_INVALID_SKU_SERVICE_OR_VENDOR_SERVICE_RESPONSE));
} else if
([Link]().contains("CataloguePersonalizationInvalidServiceResponse
Exception")){
msg =
[Link]().substring([Link]().lastIndexOf("CataloguePersonali
zationInvalidServiceResponseException:")
+"CataloguePersonalizationInvalidServiceResponseException".length()+1);
}
throw new
CataloguePersonalizationInvalidServiceResponseException([Link]());
}else{
throw new
CataloguePersonalizationGenericException("Exception occured while
fetching the output response", ex);
}
}

catch (BaseFusionJsonParserException ex) {


[Link]([Link](), ex);
}

catch (IOException ex) {


[Link]("Exception while parsing the vendor
config node.",
ex);
}

catch (IOException e) {
[Link]("Exception while parsing the everliving node for
id(s)- {}", id,e);
}

catch (IOException e) {
throw new
FusionJsonTreeDeserializeException("Failed to to parse json response for
child product details", e);
}
catch (IOException e) {
throw new FusionJsonTreeDeserializeException("Failed to to
parse json response while fetching child products", e);
}

catch (JSONException e) {
[Link]();
}

catch (Exception e) {
if([Link]().contains(DATA_NOT_FOUND_MSG)) {
throw new
FusionJsonDataNodeNotFoundException(DATA_NOT_FOUND_LOG_MSG);
}
else {
throw new CacheAssemblerJsonParserException("Failed
to fetch product data. ", e);
}
}

catch (Exception e) {
[Link]("ExecutionException while getting the data
from fallback asynchronously", [Link]());
return null;
}

catch (Exception e) {
[Link]("ExecutionException while getting the data
from getAsyncProductOOSDetailsByProductId asynchronously",
[Link]());
}

catch (NumberFormatException nfe) {


[Link]("addBeyondPlusPriceAttributesInBPlusNode :
Unable to add the Beyond Plus price attributes due to
NumberFormatException : {}",
[Link]());
}

catch (Exception e) {
[Link]("addBeyondPlusPriceAttributesInBPlusNode
Exception while calculating beyond plus price for AMP ",
[Link]());
}

catch (Exception e){


[Link]("error while fetching category
values"+[Link]());
[Link]();
}
catch (JSONException e) {
[Link]();
}

catch(Exception e) {
[Link]("Error while extracting atrributes from TOD
node Exception is :: {} ", [Link]());
attributes = (LinkedHashMap<String, String>)
[Link]().get(BBBCatalogueConstants.ATTRIBUTES_JSON);
}

catch(Exception e) {
[Link]("Error while extracting atrributes from TOD
node Exception is :: {} ", [Link]());
attributes = (LinkedHashMap<String, String>)
[Link](BBBCatalogueConstants.ATTRIBUTES_JSON);
}

catch (Exception e) {
[Link]("ERROR occurred while getting Tooltip Data " +
[Link]());
}

catch (UnsupportedEncodingException e) {

[Link]("BBBCompositeDefaultStoreDetailsUtils:callDefaultStoreByLat
LongAndSetCookies() Error while encoding the latLongCookie",
[Link]());
}

catch (ParseException e) {
[Link]("checkCountDownClockValid Error
while parsing the promotion end date {} ", promotionEnds);
}

catch (RestClientException exception) {


[Link]("getDynamicContentDataForContentKey :
Exception Occurred : {} ", [Link]());
}

catch (IOException ioe) {


[Link]("Failed to parse json text '{}' to
skuSwatchAllJsonNode,", [Link](), ioe);
}
Remark

No issue.

changes done

changes done

changes done

No issue.

changes done

changes done

No issue.
No issue.

No issue.
No issue.

No issue.

No issue.
No issue.
No issue.

No issue.

No issue.

No issue.
No issue.

No issue.

No issue.

No issue.

No issue.

No issue.
[Link]
[Link](e)
[Link] method --> / by zero NPE 20 alert
[Link] method --> ArithmeticException: / by zero

[Link]() ? e : [Link]());
Class Line

[Link]

[Link]

[Link]

[Link]
[Link]

[Link]

[Link]
[Link]

[Link]
[Link]
content Remark

catch (RequestSigningException e) {
throw new RuntimeException(e);
}

catch (IOException e) {
throw new RuntimeException(e);
}

catch (Exception e) {
StringBuilder sb = new StringBuilder();
[Link]("Article List Pregeneration for site id
'").append(siteId).append("' failed. Job name is '")

.append([Link]()).append("'");
[Link]([Link](), e);
[Link]([Link]());

[Link]([Link]());

[Link]([Link])
;
}

catch (Exception e) {
StringBuilder sb = new StringBuilder();
[Link]("Breadcrumb List Pregeneration for site id
'").append(siteId).append("' failed. Job name is '")

.append([Link]()).append("'");
[Link]([Link](), e);

[Link]([Link]());

[Link](Instant.n
ow());

[Link](ServiceStatus.E
RROR);
}
catch (Exception e) {
StringBuilder sb = new StringBuilder();
[Link]("Business Profile Data Pregeneration for
site id '").append(siteId).append("' failed. Job name is '")

.append([Link]()).append("'");
[Link]([Link](), e);

[Link]([Link]());

[Link]([Link]
w());

[Link](ServiceStatus.E
RROR);
}

catch (Exception e) {
StringBuilder sb = new StringBuilder();
[Link]("Buying Guide Data Pregeneration for site
id '").append(siteId).append("' failed. Job name is '")

.append([Link]()).append("'");
[Link]([Link](), e);
[Link]([Link]());

[Link]([Link](
));

[Link]([Link]
OR);
}

catch (Throwable e) {
[Link]("Bazaar Voice review rating generate feed XML
has thrown exception jobID ::
'").append([Link]()).append("' ");
[Link]([Link](), e);
[Link](e);
[Link]([Link]());

[Link]([Link]());

[Link]([Link]);
}
catch (Exception e) {
[Link]("' failed. Job name is
'").append([Link]()).append("'");
[Link]([Link](), e);

[Link]([Link]
w());

[Link](ServiceStatus.E
RROR);
}

catch (Exception e) {
StringBuilder sb = new StringBuilder();
[Link]("Category-Navigation Pregeneration for
site id '").append(siteId).append("' failed. Job name is '")

.append([Link]()).append("'");
[Link]([Link](), e);

[Link]([Link]());

[Link](Instan
[Link]());

[Link](ServiceStat
[Link]);
}

You might also like