Skip to content

Commit

Permalink
* refact: don't log the exception message before raising exception (#743
Browse files Browse the repository at this point in the history
)

* refact: don't log the exception message before raising
  • Loading branch information
asmfstatoil committed Jun 17, 2023
1 parent 13266ec commit 15772fd
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ public CompressorCurve getCurveAtRefSpeed(double refSpeed) {
}
}
String msg = "Does not match any speed in the chart.";
logger.error(msg);
neqsim.util.exception.InvalidInputException ex =
new neqsim.util.exception.InvalidInputException(this, "getCurveAtRefSpeed", "refSpeed",
msg);
Expand Down
1 change: 0 additions & 1 deletion src/main/java/neqsim/thermo/component/Component.java
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,6 @@ public Component clone() {
public void addMolesChemReac(double dn, double totdn) {
if (numberOfMoles + totdn < 0 || numberOfMolesInPhase + dn < 0) {
String msg = "will lead to negative number of moles of component in phase";
logger.error(msg);
neqsim.util.exception.InvalidInputException ex =
new neqsim.util.exception.InvalidInputException(this, "addMolesChemReac", "dn", msg);
throw new RuntimeException(ex);
Expand Down
1 change: 0 additions & 1 deletion src/main/java/neqsim/thermo/phase/Phase.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ public void addMoles(int component, double dn) {
public void addMolesChemReac(int component, double dn, double totdn) {
if ((numberOfMolesInPhase + dn) / numberOfMolesInPhase < -1e-10) {
String msg = "will lead to negative number of moles in phase." + (numberOfMolesInPhase + dn);
logger.error(msg);
neqsim.util.exception.InvalidInputException ex =
new neqsim.util.exception.InvalidInputException(this, "addMolesChemReac", "dn", msg);
throw new RuntimeException(ex);
Expand Down
16 changes: 1 addition & 15 deletions src/main/java/neqsim/thermo/system/SystemThermo.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,17 +166,13 @@ public SystemThermo() {
public SystemThermo(double T, double P) {
this();
if (T < 0.0) {
String msg = "Negative input temperature";
logger.error(msg);
neqsim.util.exception.InvalidInputException ex =
new neqsim.util.exception.InvalidInputException(this.getClass().getSimpleName(),
"SystemThermo", "T", "is negative");
throw new RuntimeException(ex);
}

if (P < 0.0) {
String msg = "Negative input pressure";
logger.error(msg);
neqsim.util.exception.InvalidInputException ex =
new neqsim.util.exception.InvalidInputException(this.getClass().getSimpleName(),
"SystemThermo", "P", "is negative");
Expand Down Expand Up @@ -777,14 +773,10 @@ public void addSalt(String componentName, double value) {
public void addTBPfraction(String componentName, double numberOfMoles, double molarMass,
double density) {
if (density < 0.0) {
String msg = "Negative input density.";
logger.error(msg);
throw new RuntimeException(new neqsim.util.exception.InvalidInputException(this,
"addTBPfraction", "density", "is negative."));
}
if (molarMass < 0.0) {
String msg = "Negative input molar mass.";
logger.error(msg);
throw new RuntimeException(new neqsim.util.exception.InvalidInputException(this,
"addTBPfraction", "molarMass", "is negative."));
}
Expand Down Expand Up @@ -922,15 +914,11 @@ public void addTBPfraction(String componentName, double numberOfMoles, double mo
public void addTBPfraction(String componentName, double numberOfMoles, double molarMass,
double density, double criticalTemperature, double criticalPressure, double acentricFactor) {
if (density < 0.0 || molarMass < 0.0) {
String msg = "Negative input density.";
logger.error(msg);
throw new RuntimeException(new neqsim.util.exception.InvalidInputException(this,
"addTBPfraction", "density", "is negative."));
}

if (density < 0.0 || molarMass < 0.0) {
String msg = "Negative input molar mass.";
logger.error(msg);
throw new RuntimeException(new neqsim.util.exception.InvalidInputException(this,
"addTBPfraction", "molarMass", "is negative."));
}
Expand Down Expand Up @@ -1144,8 +1132,7 @@ public void addComponent(String componentName, double moles) {
throw new RuntimeException("No component with name: " + componentName + " in database");
}
if (moles < 0.0) {
String msg = "Negative input number of moles of component: " + componentName;
logger.error(msg);
String msg = "is negative input for component: " + componentName;
throw new RuntimeException(
new neqsim.util.exception.InvalidInputException(this, "addComponent", "moles", msg));
}
Expand Down Expand Up @@ -1248,7 +1235,6 @@ public void addComponent(String componentName, double moles, int phaseNumber) {
// Add new component
if (moles < 0.0) {
String msg = "Negative input number of moles.";
logger.error(msg);
neqsim.util.exception.InvalidInputException ex =
new neqsim.util.exception.InvalidInputException(this, "addComponent", "moles", msg);
throw new RuntimeException(ex);
Expand Down

0 comments on commit 15772fd

Please sign in to comment.