         let sendHandler: ((CloudCodedResult<AssetUploadResponse>) -> Void) = {
             result in
             
-            switch result {
-            case .failure:
-                Logging.log("Data upload failed")
-            case .success(let def, _):
-                definition = def.singleFile
+            if let file = result.result?.singleFile {
+                definition = file
+            } else if let error = result.error {
+                Logging.error("Upload asset data error: \(error)")
+            } else {
+                Logging.log("Uploaded asset data and nothing happened?")
             }
         }
         send(raw: data, to: target.url, completion: sendHandler)


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 {

    }
    
    private func handleCodedResult<R: Decodable>(data: Data?, response: URLResponse?, error: Error?, completion: @escaping ((CloudCodedResult<R>) -> ())) {
        var result: R? = nil
        var cloudError: CloudError? = nil
        
        defer {
            completion(CloudCodedResult(result: result, error: cloudError, continuation: nil))
        }
        
        guard let responseData = data else {
            Logging.log("No response data")
            cloudError = .noData
            return
        }
        
        do {
            result = try decoder.decode(R.self, from: responseData)
        } catch {
            Logging.error("Decode error \(error)")
            cloudError = .decode(error)
        }
    }
}

