1
1
/// Evaluates a throwing closure and automatically catches and reports any error thrown.
2
2
///
3
3
/// - Parameters:
4
+ /// - message: A message describing the expectation.
4
5
/// - reporters: Issue reporters to notify during the operation.
5
6
/// - fileID: The source `#fileID` associated with the error reporting.
6
7
/// - filePath: The source `#filePath` associated with the error reporting.
10
11
/// - Returns: The optional result of the operation, or `nil` if an error was thrown.
11
12
@_transparent
12
13
public func withErrorReporting< R> (
13
- _ reporters: [ any IssueReporter ] ? = nil ,
14
+ _ message: @autoclosure ( ) -> String ? = nil ,
15
+ to reporters: [ any IssueReporter ] ? = nil ,
14
16
fileID: StaticString = #fileID,
15
17
filePath: StaticString = #filePath,
16
18
line: UInt = #line,
@@ -22,15 +24,29 @@ public func withErrorReporting<R>(
22
24
do {
23
25
return try body ( )
24
26
} catch {
25
- reportIssue ( error, fileID: fileID, filePath: filePath, line: line, column: column)
27
+ reportIssue (
28
+ error,
29
+ message ( ) ,
30
+ fileID: fileID,
31
+ filePath: filePath,
32
+ line: line,
33
+ column: column
34
+ )
26
35
return nil
27
36
}
28
37
}
29
38
} else {
30
39
do {
31
40
return try body ( )
32
41
} catch {
33
- reportIssue ( error, fileID: fileID, filePath: filePath, line: line, column: column)
42
+ reportIssue (
43
+ error,
44
+ message ( ) ,
45
+ fileID: fileID,
46
+ filePath: filePath,
47
+ line: line,
48
+ column: column
49
+ )
34
50
return nil
35
51
}
36
52
}
@@ -39,6 +55,7 @@ public func withErrorReporting<R>(
39
55
/// Evaluates a throwing closure and automatically catches and reports any error thrown.
40
56
///
41
57
/// - Parameters:
58
+ /// - message: A message describing the expectation.
42
59
/// - reporters: Issue reporters to notify during the operation.
43
60
/// - fileID: The source `#fileID` associated with the error reporting.
44
61
/// - filePath: The source `#filePath` associated with the error reporting.
@@ -48,7 +65,8 @@ public func withErrorReporting<R>(
48
65
/// - Returns: The optional result of the operation, or `nil` if an error was thrown.
49
66
@_transparent
50
67
public func withErrorReporting< R> (
51
- _ reporters: [ any IssueReporter ] ? = nil ,
68
+ _ message: @autoclosure ( ) -> String ? = nil ,
69
+ to reporters: [ any IssueReporter ] ? = nil ,
52
70
fileID: StaticString = #fileID,
53
71
filePath: StaticString = #filePath,
54
72
line: UInt = #line,
0 commit comments