Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions mllib/src/test/scala/org/apache/spark/ml/util/MLTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,15 @@ trait MLTest extends StreamTest with TempDirectory { self: Suite =>
expectedMessagePart : String,
firstResultCol: String) {

def hasExpectedMessageDirectly(exception: Throwable): Boolean =
exception.getMessage.contains(expectedMessagePart)

def hasExpectedMessage(exception: Throwable): Boolean =
exception.getMessage.contains(expectedMessagePart) ||
(exception.getCause != null && exception.getCause.getMessage.contains(expectedMessagePart))
hasExpectedMessageDirectly(exception) || (
exception.getCause != null && (
hasExpectedMessageDirectly(exception.getCause) || (
exception.getCause.getCause != null &&
hasExpectedMessageDirectly(exception.getCause.getCause))))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use a loop to check inner exception ? So it can check any deep level exception msg.
Maybe we cannot make sure the possible root exception max level (even in master version)
@jkbradley What do you think ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to loop further. If the real message is buried this deep, that could be considered a problem in and of itself.


withClue(s"""Expected message part "${expectedMessagePart}" is not found in DF test.""") {
val exceptionOnDf = intercept[Throwable] {
Expand Down