withErrorReporting(_:to:fileID:filePath:line:column:catching:)
Evaluates a throwing closure and automatically catches and reports any error thrown.
func withErrorReporting<R>(_ message: @autoclosure () -> String? = nil, to reporters: [any IssueReporter]? = nil, fileID: StaticString = #fileID, filePath: StaticString = #filePath, line: UInt = #line, column: UInt = #column, catching body: () throws -> R) -> R?
Parameters
- message
A message describing the expectation.
- reporters
Issue reporters to notify during the operation.
- fileID
The source
#fileID
associated with the error reporting.- filePath
The source
#filePath
associated with the error reporting.- line
The source
#line
associated with the error reporting.- column
The source
#column
associated with the error reporting.- body
A synchronous operation.
Returns
The optional result of the operation, or nil
if an error was thrown.
Overloads
func withErrorReporting<R>(@autoclosure () -> String?, to: [any IssueReporter]?, fileID: StaticString, filePath: StaticString, line: UInt, column: UInt, isolation: isolated (any Actor)?, catching: () async throws -> sending R
) async -> R? Evaluates a throwing closure and automatically catches and reports any error thrown.