Skip to content

Commit

Permalink
On any RuntimeException flag shipmentCandidate as "error" an move on (#…
Browse files Browse the repository at this point in the history
…10247)

also, avoid NPE is streetno is missing
  • Loading branch information
metas-ts committed Nov 17, 2020
1 parent e6fff6e commit 46837bc
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public JsonResponseShipmentCandidates exportShipmentCandidates(@NonNull final Qu
result.item(itemBuilder.build());
createExportedAuditItem(shipmentSchedule, auditBuilder);
}
catch (final ShipmentCandidateExportException e) // don't catch just any exception; just the "functional" ones
catch (final RuntimeException e) // catch all RTEs; if we don't catch them here, then the whole export won't proceed, for no shipment candidate
{
createExportErrorAuditItem(shipmentSchedule, e, auditBuilder);
}
Expand Down Expand Up @@ -281,9 +281,9 @@ private JsonCustomer createJsonCustomer(
.setParameter("C_BPartner_Location_ID", bPartnerLocationId.getRepoId()));

final IPair<String, String> splitStreetAndHouseNumber = StringUtils.splitStreetAndHouseNumberOrNull(location.getAddress1());
if (splitStreetAndHouseNumber == null)
if (splitStreetAndHouseNumber == null || splitStreetAndHouseNumber.getLeft() == null || splitStreetAndHouseNumber.getRight() == null)
{
throw new ShipmentCandidateExportException("BPartner's location needs to have an Address1 with a discernible street and street number")
throw new ShipmentCandidateExportException("Unable to extract street and street-number from Address1")
.appendParametersToMessage()
.setParameter("Address1", location.getAddress1())
.setParameter("C_BPartner_ID", composite.getBpartner().getId().getRepoId())
Expand Down Expand Up @@ -392,7 +392,7 @@ private void createExportedAuditItem(

private void createExportErrorAuditItem(
@NonNull final ShipmentSchedule shipmentSchedule,
@NonNull final ShipmentCandidateExportException e,
@NonNull final RuntimeException e,
@NonNull final APIExportAuditBuilder<ShipmentScheduleExportAuditItem> auditBuilder)
{
final OrgId orgId = shipmentSchedule.getOrgId();
Expand Down

0 comments on commit 46837bc

Please sign in to comment.