Skip to content

Commit

Permalink
Improve Exception Message to also log the quantity kind of the unit
Browse files Browse the repository at this point in the history
conversion - (Task #1224)
  • Loading branch information
dellerDLR committed Oct 30, 2024
1 parent 5521a33 commit c30b571
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1243,10 +1243,11 @@ public List<AQuantityKind> getQuantityKindByBaseKinds(SystemOfQuantities systemO
public double convertFromSourceToTargetUnit(AUnit sourceUnit, double sourceValue, AUnit targetUnit) throws IllegalArgumentException {
double convertedValue = 0.0;
if (!haveSameQuantityKind(sourceUnit, targetUnit)) {
throw new IllegalArgumentException("Cannot convert from " + sourceUnit.getName() + " to " + targetUnit.getName()
+ " as they have different quantitiy kinds!");
throw new IllegalArgumentException("Cannot convert from " + sourceUnit.getName() + " with quantity kind "+ sourceUnit.getQuantityKind() +
" to " + targetUnit.getName() + "with quantity kind" + targetUnit.getQuantityKind() + " as they have different quantitiy kinds!");
}


//we convert the source Unit to the basUnits and then to the given target unit
convertedValue = convertFromSourceUnitToBaseUnit(sourceUnit, sourceValue);
convertedValue = convertFromBaseUnitToTargetUnit(targetUnit, convertedValue);
Expand Down

0 comments on commit c30b571

Please sign in to comment.