Skip to content

Commit 8b4e489

Browse files
committed
Pass message along in async withErrorReporting
1 parent 9243488 commit 8b4e489

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

Sources/IssueReporting/ErrorReporting.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,22 @@ public func withErrorReporting<R>(
7878
do {
7979
return try await body()
8080
} catch {
81-
reportIssue(error, fileID: fileID, filePath: filePath, line: line, column: column)
81+
reportIssue(
82+
error,
83+
message(),
84+
fileID: fileID,
85+
filePath: filePath,
86+
line: line,
87+
column: column
88+
)
8289
return nil
8390
}
8491
}
8592
} else {
8693
do {
8794
return try await body()
8895
} catch {
89-
reportIssue(error, fileID: fileID, filePath: filePath, line: line, column: column)
96+
reportIssue(error, message(), fileID: fileID, filePath: filePath, line: line, column: column)
9097
return nil
9198
}
9299
}

Tests/IssueReportingTests/WithErrorReportingTests.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,24 @@
2121
issue.description == "Caught error: SomeError(): Failed"
2222
}
2323
}
24+
25+
@Test func overload() async {
26+
await withKnownIssue {
27+
await withErrorReporting { () async throws in
28+
throw SomeError()
29+
}
30+
} matching: { issue in
31+
issue.description == "Caught error: SomeError()"
32+
}
33+
34+
await withKnownIssue {
35+
await withErrorReporting("Failed") { () async throws in
36+
throw SomeError()
37+
}
38+
} matching: { issue in
39+
issue.description == "Caught error: SomeError(): Failed"
40+
}
41+
}
2442
}
2543

2644
private struct SomeError: Error {}

0 commit comments

Comments
 (0)