Instance Methodswift-package-manager 6.0.3Basics
trap(_:)
trap a throwing closure, emitting diagnostics on error and returning the value returned by the closure
func trap<T>(_ closure: () throws -> T) -> T?
trap a throwing closure, emitting diagnostics on error and returning the value returned by the closure
func trap<T>(_ closure: () throws -> T) -> T?
s6Basics26DiagnosticsEmitterProtocolPAAE4trapyqd__Sgqd__yKXElF
What are these?9V0VA
import Basics
protocol DiagnosticsEmitterProtocol
func emit(_ diagnostics: [Diagnostic])
func emit(_ error: Error, metadata: ObservabilityMetadata? = .none)
func emit(debug message: String, metadata: ObservabilityMetadata? = .none, underlyingError: Error? = .none)
func emit(debug message: CustomStringConvertible, metadata: ObservabilityMetadata? = .none, underlyingError: Error? = .none)
func emit(error message: String, metadata: ObservabilityMetadata? = .none, underlyingError: Error? = .none)
func emit(error message: CustomStringConvertible, metadata: ObservabilityMetadata? = .none, underlyingError: Error? = .none)
func emit(info message: String, metadata: ObservabilityMetadata? = .none, underlyingError: Error? = .none)
func emit(info message: CustomStringConvertible, metadata: ObservabilityMetadata? = .none, underlyingError: Error? = .none)
func emit(severity: Diagnostic.Severity, message: String, metadata: ObservabilityMetadata? = .none)
func emit(warning message: String, metadata: ObservabilityMetadata? = .none, underlyingError: Error? = .none)
func emit(warning message: CustomStringConvertible, metadata: ObservabilityMetadata? = .none, underlyingError: Error? = .none)
@discardableResult func trap(_ closure: () throws -> Void) -> Bool
trap a throwing closure, emitting diagnostics on error and returning boolean representing success