From a0916987d0adacc2e0ebd1801b0b806cfe59cfe3 Mon Sep 17 00:00:00 2001
From: Dariusz Rybicki <dariusz@elixxir.io>
Date: Wed, 3 Aug 2022 21:32:47 +0100
Subject: [PATCH] Add UpdateCommonErrors functor

---
 .../Functors/UpdateCommonErrors.swift         | 32 +++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100644 Sources/ElixxirDAppsSDK/Functors/UpdateCommonErrors.swift

diff --git a/Sources/ElixxirDAppsSDK/Functors/UpdateCommonErrors.swift b/Sources/ElixxirDAppsSDK/Functors/UpdateCommonErrors.swift
new file mode 100644
index 00000000..32d195f6
--- /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)")
+  )
+}
-- 
GitLab