Skip to content

Commit

Permalink
Merge pull request #123 from LEMS/experimental
Browse files Browse the repository at this point in the history
Propagate content error for dimensional check failures
  • Loading branch information
pgleeson authored Jun 18, 2024
2 parents 40d8ff1 + 41c0276 commit a6c1661
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
4 changes: 2 additions & 2 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
<javac srcdir="src"
destdir="build"
debug="true"
source="1.6"
target="1.6"
source="1.8"
target="1.8"
includeantruntime="false"
classpathref="junit.classpath">
<include name="**/*.java"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,12 @@ public void checkDimensions(HashMap<String, Dimensional> dimHM) throws ContentEr
if (dres.isDimensionless()) {
// OK
} else {
E.oneLineError("Dimension mismatch in equation: " + variable + " = " + value + ". Residual dimension: " + dres);
E.info("Dimension of " + variable + ": " + dsv + ", multiplier=" + dlf + ", left=" + dl + ", rhs=" + drhs);
E.info("All:" + dimHM);

String errmsg = ("Dimension mismatch in the equation: " + variable + " = " + value + ". Residual dimension: " + dres +
"\nDimension of " + variable + ": " + dsv + ", multiplier=" + dlf + ", left=" + dl + ", rhs=" + drhs +
"\nAll:" + dimHM);
E.info(errmsg);
throw new ContentError(errmsg);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ public Valued getValued(String select) throws ContentError {



public void checkEquations(HashMap<String, Dimensional> cdimHM) throws ContentError {
public void checkEquations(HashMap<String, Dimensional> cdimHM) throws ContentError{

HashMap<String, Dimensional> dimHM = new HashMap<String, Dimensional>();

Expand Down Expand Up @@ -559,15 +559,18 @@ public void checkEquations(HashMap<String, Dimensional> cdimHM) throws ContentEr
try {
dimHM.put(dv.getName(), dv.getDimensionality(dimHM));
} catch (ContentError ce) {
E.error("Checking " + dv + " in " + r_type + " " + ce.getMessage());
String errmsg = ("Checking " + dv + " in " + r_type + " " + ce.getMessage());
throw new ContentError(errmsg);

}
}

for (ConditionalDerivedVariable cdv : conditionalDerivedVariables) {
try {
dimHM.put(cdv.getName(), cdv.getDimensionality(dimHM));
} catch (ContentError ce) {
E.error("Checking " + cdv + " in " + r_type + " " + ce.getMessage());
String errmsg = "Checking " + cdv + " in " + r_type + " " + ce.getMessage();
throw new ContentError(errmsg);
}
}

Expand Down

0 comments on commit a6c1661

Please sign in to comment.