Skip to content

Commit

Permalink
Update exception message to be more generic so it is not misleading
Browse files Browse the repository at this point in the history
Signed-off-by: Steven Ayers <[email protected]>
  • Loading branch information
stevenayers committed Sep 16, 2024
1 parent 856a392 commit c410c53
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ sealed trait DeltaSharingProfile {
private [client] def validate(): Unit = {
if (shareCredentialsVersion.isEmpty) {
throw new IllegalArgumentException(
"Cannot find the 'shareCredentialsVersion' field in the profile file")
"Cannot find the 'shareCredentialsVersion' field in the profile")
}

if (shareCredentialsVersion.get > DeltaSharingProfile.CURRENT) {
Expand Down Expand Up @@ -143,14 +143,14 @@ object DeltaSharingProfile {
private [client] def validateNotNullAndEmpty(fieldValue: String,
fieldName: String): Unit = {
if (fieldValue == null || fieldValue.isEmpty) {
throw new IllegalArgumentException(s"Cannot find the '$fieldName' field in the profile file")
throw new IllegalArgumentException(s"Cannot find the '$fieldName' field in the profile")
}
}

private [client] def validateNotNullAndEmpty(fieldValue: Option[Long],
fieldName: String): Unit = {
if (fieldValue == null || fieldValue.isEmpty) {
throw new IllegalArgumentException(s"Cannot find the '$fieldName' field in the profile file")
throw new IllegalArgumentException(s"Cannot find the '$fieldName' field in the profile")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class DeltaSharingFileProfileProviderSuite extends SparkFunSuite {
)
}
assert(e.getMessage.contains(
"Cannot find the 'shareCredentialsVersion' field in the profile file"))
"Cannot find the 'shareCredentialsVersion' field in the profile"))
}

test("shareCredentialsVersion is incorrect") {
Expand Down Expand Up @@ -126,7 +126,7 @@ class DeltaSharingFileProfileProviderSuite extends SparkFunSuite {
null
)
}
assert(e.getMessage.contains("Cannot find the 'endpoint' field in the profile file"))
assert(e.getMessage.contains("Cannot find the 'endpoint' field in the profile"))
}

test("bearerToken is missing") {
Expand All @@ -140,7 +140,7 @@ class DeltaSharingFileProfileProviderSuite extends SparkFunSuite {
null
)
}
assert(e.getMessage.contains("Cannot find the 'bearerToken' field in the profile file"))
assert(e.getMessage.contains("Cannot find the 'bearerToken' field in the profile"))
}

test("unknown field should be ignored") {
Expand Down Expand Up @@ -241,7 +241,7 @@ class DeltaSharingFileProfileProviderSuite extends SparkFunSuite {
val e = intercept[IllegalArgumentException] {
testProfile(profile, null)
}
assert(e.getMessage.contains(s"Cannot find the '$missingField' field in the profile file"))
assert(e.getMessage.contains(s"Cannot find the '$missingField' field in the profile"))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class DeltaSharingOptionsProfileProviderSuite extends SparkFunSuite {
)
}
assert(e.getMessage.contains(
"Cannot find the 'shareCredentialsVersion' field in the profile file"))
"Cannot find the 'shareCredentialsVersion' field in the profile"))
}

test("shareCredentialsVersion is incorrect") {
Expand Down Expand Up @@ -112,7 +112,7 @@ class DeltaSharingOptionsProfileProviderSuite extends SparkFunSuite {
null
)
}
assert(e.getMessage.contains("Cannot find the 'endpoint' field in the profile file"))
assert(e.getMessage.contains("Cannot find the 'endpoint' field in the profile"))
}

test("bearerToken is missing") {
Expand All @@ -125,7 +125,7 @@ class DeltaSharingOptionsProfileProviderSuite extends SparkFunSuite {
null
)
}
assert(e.getMessage.contains("Cannot find the 'bearerToken' field in the profile file"))
assert(e.getMessage.contains("Cannot find the 'bearerToken' field in the profile"))
}

test("unknown field should be ignored") {
Expand Down Expand Up @@ -221,7 +221,7 @@ class DeltaSharingOptionsProfileProviderSuite extends SparkFunSuite {
val e = intercept[IllegalArgumentException] {
testProfile(profile, null)
}
assert(e.getMessage.contains(s"Cannot find the '$missingField' field in the profile file"))
assert(e.getMessage.contains(s"Cannot find the '$missingField' field in the profile"))
}
}

Expand Down

0 comments on commit c410c53

Please sign in to comment.