Skip to content

Commit

Permalink
cleaner exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Shawn Chang committed Jul 21, 2022
1 parent 19e2774 commit 0fdc134
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,8 @@ class HoodieSparkSqlTestBase extends FunSuite with BeforeAndAfterAll {
try {
spark.sql(sql)
} catch {
case e: Throwable =>
if (e.getMessage.contains(errorMsg)) {
hasException = true
} else {
fail("Exception should contain: " + errorMsg + ", error message: " + e.getMessage, e)
}
case e: Throwable if e.getMessage.contains(errorMsg) => hasException = true
case f: Throwable => fail("Exception should contain: " + errorMsg + ", error message: " + f.getMessage, f)
}
assertResult(true)(hasException)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,8 @@ class TestCallCommandParser extends HoodieSparkSqlTestBase {
try {
parser.parsePlan(sql)
} catch {
case e: Throwable =>
if (e.getMessage.contains(errorMsg)) {
hasException = true
} else {
fail("Exception should contain: " + errorMsg + ", error message: " + e.getMessage, e)
}
case e: Throwable if e.getMessage.contains(errorMsg) => hasException = true
case f: Throwable => fail("Exception should contain: " + errorMsg + ", error message: " + f.getMessage, f)
}
assertResult(true)(hasException)
}
Expand Down

0 comments on commit 0fdc134

Please sign in to comment.