@@ -77,17 +77,15 @@ public func withErrorReporting<R>(
7777 column: UInt = #column,
7878 catching body: ( ) throws -> R ?
7979) -> R ? {
80- (
81- withErrorReporting (
82- message ( ) ,
83- to: reporters,
84- fileID: fileID,
85- filePath: filePath,
86- line: line,
87- column: column,
88- catching: body
89- ) as R ??
90- ) ?? nil
80+ ( withErrorReporting (
81+ message ( ) ,
82+ to: reporters,
83+ fileID: fileID,
84+ filePath: filePath,
85+ line: line,
86+ column: column,
87+ catching: body
88+ ) as R ?? ) ?? nil
9189}
9290
9391#if compiler(>=6)
@@ -148,41 +146,40 @@ public func withErrorReporting<R>(
148146 }
149147 }
150148
151- /// Evaluates a throwing closure and automatically catches and reports any error thrown.
152- ///
153- /// - Parameters:
154- /// - message: A message describing the expectation.
155- /// - reporters: Issue reporters to notify during the operation.
156- /// - fileID: The source `#fileID` associated with the error reporting.
157- /// - filePath: The source `#filePath` associated with the error reporting.
158- /// - line: The source `#line` associated with the error reporting.
159- /// - column: The source `#column` associated with the error reporting.
160- /// - isolation: The isolation associated with the error reporting.
161- /// - body: An asynchronous operation.
162- /// - Returns: The optional result of the operation, or `nil` if an error was thrown.
163- @_transparent
164- public func withErrorReporting< R> (
165- _ message: @autoclosure ( ) -> String ? = nil ,
166- to reporters: [ any IssueReporter ] ? = nil ,
167- fileID: StaticString = #fileID,
168- filePath: StaticString = #filePath,
169- line: UInt = #line,
170- column: UInt = #column,
171- isolation: isolated ( any Actor ) ? = #isolation,
172- // DO NOT FIX THE WHITESPACE IN THE NEXT LINE UNTIL 5.10 IS UNSUPPORTED
173- // https://github.com/swiftlang/swift/issues/79285
174- catching body: ( ) async throws -> sending R? ) async -> R ? {
175- (
176- await withErrorReporting (
177- message ( ) ,
178- to: reporters,
179- fileID: fileID,
180- filePath: filePath,
181- line: line,
182- column: column,
183- catching: body
184- ) as R ??
185- ) ?? nil
149+ /// Evaluates a throwing closure and automatically catches and reports any error thrown.
150+ ///
151+ /// - Parameters:
152+ /// - message: A message describing the expectation.
153+ /// - reporters: Issue reporters to notify during the operation.
154+ /// - fileID: The source `#fileID` associated with the error reporting.
155+ /// - filePath: The source `#filePath` associated with the error reporting.
156+ /// - line: The source `#line` associated with the error reporting.
157+ /// - column: The source `#column` associated with the error reporting.
158+ /// - isolation: The isolation associated with the error reporting.
159+ /// - body: An asynchronous operation.
160+ /// - Returns: The optional result of the operation, or `nil` if an error was thrown.
161+ @_transparent
162+ public func withErrorReporting< R> (
163+ _ message: @autoclosure ( ) -> String ? = nil ,
164+ to reporters: [ any IssueReporter ] ? = nil ,
165+ fileID: StaticString = #fileID,
166+ filePath: StaticString = #filePath,
167+ line: UInt = #line,
168+ column: UInt = #column,
169+ isolation: isolated ( any Actor ) ? = #isolation,
170+ // DO NOT FIX THE WHITESPACE IN THE NEXT LINE UNTIL 5.10 IS UNSUPPORTED
171+ // https://github.com/swiftlang/swift/issues/79285
172+ catching body: ( ) async throws -> sending R?
173+ ) async -> R ? {
174+ ( await withErrorReporting (
175+ message ( ) ,
176+ to: reporters,
177+ fileID: fileID,
178+ filePath: filePath,
179+ line: line,
180+ column: column,
181+ catching: body
182+ ) as R ?? ) ?? nil
186183 }
187184#else
188185 @_transparent
@@ -229,80 +226,25 @@ public func withErrorReporting<R>(
229226 }
230227 }
231228
232- @_transparent
233- @_unsafeInheritExecutor
234- public func withErrorReporting< R> (
235- _ message: @autoclosure ( ) -> String ? = nil ,
236- to reporters: [ any IssueReporter ] ? = nil ,
237- fileID: StaticString = #fileID,
238- filePath: StaticString = #filePath,
239- line: UInt = #line,
240- column: UInt = #column,
241- catching body: ( ) async throws -> R ?
242- ) async -> R ? {
243- if let reporters {
244- return await withIssueReporters ( reporters) {
245- do {
246- if let body = try body ( ) {
247- return body
248- } else {
249- return nil
250- }
251- } catch {
252- reportIssue (
253- error,
254- message ( ) ,
255- fileID: fileID,
256- filePath: filePath,
257- line: line,
258- column: column
259- )
260- return nil
261- }
262- }
263- } else {
264- do {
265- if let body = try body ( ) {
266- return body
267- } else {
268- return nil
269- }
270- } catch {
271- reportIssue (
272- error,
273- message ( ) ,
274- fileID: fileID,
275- filePath: filePath,
276- line: line,
277- column: column
278- )
279- return nil
280- }
281- }
282- }
283-
284- @_transparent
285- @_unsafeInheritExecutor
286- public func withErrorReporting< R> (
287- _ message: @autoclosure ( ) -> String ? = nil ,
288- to reporters: [ any IssueReporter ] ? = nil ,
289- fileID: StaticString = #fileID,
290- filePath: StaticString = #filePath,
291- line: UInt = #line,
292- column: UInt = #column,
293- // DO NOT FIX THE WHITESPACE IN THE NEXT LINE UNTIL 5.10 IS UNSUPPORTED
294- // https://github.com/swiftlang/swift/issues/79285
295- catching body: ( ) async throws -> sending R? ) async -> R ? {
296- (
297- await withErrorReporting (
298- message ( ) ,
299- to: reporters,
300- fileID: fileID,
301- filePath: filePath,
302- line: line,
303- column: column,
304- catching: body
305- ) as R ??
306- ) ?? nil
229+ @_transparent
230+ @_unsafeInheritExecutor
231+ public func withErrorReporting< R> (
232+ _ message: @autoclosure ( ) -> String ? = nil ,
233+ to reporters: [ any IssueReporter ] ? = nil ,
234+ fileID: StaticString = #fileID,
235+ filePath: StaticString = #filePath,
236+ line: UInt = #line,
237+ column: UInt = #column,
238+ catching body: ( ) async throws -> R ?
239+ ) async -> R ? {
240+ ( await withErrorReporting (
241+ message ( ) ,
242+ to: reporters,
243+ fileID: fileID,
244+ filePath: filePath,
245+ line: line,
246+ column: column,
247+ catching: body
248+ ) as R ?? ) ?? nil
307249 }
308250#endif
0 commit comments