Skip to content

Commit 10e86f4

Browse files
authored
Remove unused local error type from Runner._withErrorHandling(...) (#299)
1 parent 9940ed1 commit 10e86f4

File tree

1 file changed

+5
-19
lines changed

1 file changed

+5
-19
lines changed

Sources/Testing/Running/Runner.swift

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -65,31 +65,17 @@ extension Runner {
6565
///
6666
/// This function encapsulates the standard error handling performed by
6767
/// ``Runner`` when running a test or test case.
68-
private func _withErrorHandling(sourceLocation: SourceLocation, _ body: () async throws -> Void) async throws -> Void {
68+
private func _withErrorHandling(sourceLocation: SourceLocation, _ body: () async throws -> Void) async {
6969
// Ensure that we are capturing backtraces for errors before we start
7070
// expecting to see them.
7171
Backtrace.startCachingForThrownErrors()
7272
defer {
7373
Backtrace.flushThrownErrorCache()
7474
}
7575

76-
// A local error type that represents an error that was already handled in
77-
// a previous scope.
78-
//
79-
// Instances of this type are thrown from this function after any other
80-
// error is caught. Subsequent outer calls to this function will then
81-
// avoid producing events for the same error. We bother doing this at all
82-
// because we may need to cancel the parent task after a child task is
83-
// cancelled, and the simplest way to do so is to just keep rethrowing.
84-
struct AlreadyHandled: Error {}
85-
8676
do {
8777
try await body()
8878

89-
} catch is AlreadyHandled {
90-
// This error stands in for an earlier error that should not be reported
91-
// again. It is not converted to an event.
92-
9379
} catch is ExpectationFailedError {
9480
// This error is thrown by `__check()` to indicate that its condition
9581
// evaluated to `false`. That function emits its own issue, so we don't
@@ -252,8 +238,8 @@ extension Runner {
252238
}
253239

254240
if let step = stepGraph.value, case .run = step.action {
255-
try await Test.withCurrent(step.test) {
256-
try await _withErrorHandling(sourceLocation: step.test.sourceLocation) {
241+
await Test.withCurrent(step.test) {
242+
await _withErrorHandling(sourceLocation: step.test.sourceLocation) {
257243
try await _executeTraits(for: step, testCase: nil) {
258244
// Run the test function at this step (if one is present.)
259245
if let testCases = step.test.testCases {
@@ -320,9 +306,9 @@ extension Runner {
320306
Event.post(.testCaseEnded, for: step.test, testCase: testCase, configuration: configuration)
321307
}
322308

323-
try await Test.Case.withCurrent(testCase) {
309+
await Test.Case.withCurrent(testCase) {
324310
let sourceLocation = step.test.sourceLocation
325-
try await _withErrorHandling(sourceLocation: sourceLocation) {
311+
await _withErrorHandling(sourceLocation: sourceLocation) {
326312
try await withTimeLimit(for: step.test, configuration: configuration) {
327313
try await _executeTraits(for: step, testCase: testCase) {
328314
try await testCase.body()

0 commit comments

Comments
 (0)