         let createHandler: ((CloudCodedResult<AssetCreateResponse>) -> Void) = {
             result in
             
-            switch result {
-            case .failure:
-                target = nil
-            case .success(let result, _):
-                target = result.tokens.first
+            if let token = result.result?.tokens.first {
+                target = token
+            } else if let error = result.error {
+                Logging.error("Crate asset error: \(error)")
+            } else {
+                Logging.log("Creating asset record and nothing happened?")
             }
         }
         


import Foundation

public enum CloudResult<T: RemoteRecord> {
    case success([T], (() -> ())?)
    case failure
}

public enum CloudCodedResult<T: Decodable> {
    case success(T, (() -> ())?)
    case failure
}

public class CloudContainer {

        
        fetch.fetch(request: request as URLRequest) {
            data, response, error in
            
            var cloudError: CloudError? = nil
            var result: R? = nil
            var continuation: (() -> Void)? = nil
            
            defer {
                completion(CloudCodedResult(result: result, error: cloudError, continuation: continuation))
            }

            if let error = error {
                Logging.log(error)
                cloudError = .network(error)
                return
            }

            guard let received = data else {
                Logging.log("No response data")
                cloudError = .noData
                return
            }

            do {
                result = try self.decoder.decode(R.self, from: received)
            } catch {
                Logging.error("Response not decoded: \(error)")
                cloudError = .decode(error)
            }
        }
    }
}
