diff --git a/Sources/ElixxirDAppsSDK/Functors/UpdateCommonErrors.swift b/Sources/ElixxirDAppsSDK/Functors/UpdateCommonErrors.swift new file mode 100644 index 0000000000000000000000000000000000000000..32d195f66f05c8ffc6e77ca868c588573da00cdb --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Functors/UpdateCommonErrors.swift @@ -0,0 +1,32 @@ +import Bindings +import XCTestDynamicOverlay + +public struct UpdateCommonErrors { + public var run: (String) throws -> Void + + public func callAsFunction(jsonFile: String) throws { + try run(jsonFile) + } +} + +extension UpdateCommonErrors { + public static let live = UpdateCommonErrors { jsonFile in + var error: NSError? + let result = BindingsUpdateCommonErrors( + jsonFile, + &error + ) + if let error = error { + throw error + } + guard result else { + fatalError("BindingsUpdateCommonErrors returned `false` without providing error") + } + } +} + +extension UpdateCommonErrors { + public static let unimplemented = UpdateCommonErrors( + run: XCTUnimplemented("\(Self.self)") + ) +}