Skip to content

Commit

Permalink
Suppress class name in exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
robfletcher committed Apr 25, 2021
1 parent 2ff8361 commit 8f44bd9
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import strikt.api.Status
import strikt.api.Status.Failed
import strikt.api.Status.Passed
import strikt.api.Status.Pending
import strikt.internal.opentest4j.AssertionFailed
import strikt.internal.opentest4j.CompoundAssertionFailure
import strikt.internal.opentest4j.IncompleteAssertion
import strikt.internal.reporting.writePartialToString
Expand Down Expand Up @@ -209,14 +210,14 @@ internal sealed class AssertionStrategy {
failed: Failed?,
): AssertionFailedError {
val error = if (failed?.comparison != null)
AssertionFailedError(
AssertionFailed(
message,
failed.comparison.expected,
failed.comparison.actual,
failed.cause
)
else
AssertionFailedError(
AssertionFailed(
message,
failed?.cause
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package strikt.internal.opentest4j

import org.opentest4j.AssertionFailedError

class AssertionFailed : AssertionFailedError {
constructor(message: String, expected: Any?, actual: Any?, cause: Throwable?) :
super(message, expected, actual, cause)

constructor(message: String, cause: Throwable?) : super(message, cause)

override fun toString(): String = localizedMessage
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ import org.opentest4j.MultipleFailuresError
internal class CompoundAssertionFailure(
override val message: String,
errors: List<Throwable>
) : MultipleFailuresError("", errors)
) : MultipleFailuresError("", errors) {
override fun toString(): String = localizedMessage
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@ import org.opentest4j.IncompleteExecutionException
* 1. a mapping function was called but not ultimate followed by an assertion, or
* 2. a block is empty.
*/
class IncompleteAssertion :
IncompleteExecutionException("Incomplete assertion (empty block or mapping not terminated with an assertion)")
class IncompleteAssertion : IncompleteExecutionException(
"Incomplete assertion (empty block or mapping not terminated with an assertion)"
) {
override fun toString(): String = localizedMessage
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import org.opentest4j.IncompleteExecutionException
* [strikt.api.Assertion.Builder.get] or [strikt.api.Assertion.Builder.with]
* failed due to an exception thrown by the mapping function.
*/
class MappingFailed(description: String, cause: Throwable) :
IncompleteExecutionException(
"Mapping '$description' failed with: ${cause.message}",
cause
)
class MappingFailed(description: String, cause: Throwable) : IncompleteExecutionException(
"Mapping '$description' failed with: ${cause.message}",
cause
) {
override fun toString(): String = localizedMessage
}

0 comments on commit 8f44bd9

Please sign in to comment.