maropu commented on a change in pull request #27700: [SQL][TESTS][MINOR] Use intercept instead of try-catch to assert failures in IntervalUtilsSuite URL: https://github.com/apache/spark/pull/27700#discussion_r384333961
########## File path: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/util/IntervalUtilsSuite.scala ########## @@ -215,13 +172,9 @@ class IntervalUtilsSuite extends SparkFunSuite with SQLHelper { assert(duration("1 microsecond", TimeUnit.MICROSECONDS, 30) === 1) assert(duration("1 month -30 days", TimeUnit.DAYS, 31) === 1) - try { - duration(Integer.MAX_VALUE + " month", TimeUnit.SECONDS, 31) - fail("Expected to throw an exception for the invalid input") - } catch { - case e: ArithmeticException => - assert(e.getMessage.contains("overflow")) - } + val e = + intercept[ArithmeticException](duration(Integer.MAX_VALUE + " month", TimeUnit.SECONDS, 31)) Review comment: nit: ``` val e = intercept[ArithmeticException] { duration(Integer.MAX_VALUE + " month", TimeUnit.SECONDS, 31) } ``` ? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org