         }
     }
     
-    var errorContainer: ErrorContainer? {
+    var error: HNTaskError? {
         get {
-            return doInLock { () -> ErrorContainer? in
-                return self._errorContainer
-            }
-        }
-    }
-    
-    var error: Any? {
-        get {
-            return doInLock { () -> Any? in
-                if let errorContainer = self._errorContainer {
-                    return errorContainer.value
-                } else {
-                    return nil
-                }
+            return doInLock { () -> HNTaskError? in
+                return self._error
             }
         }
     }
     
     func isError() -> Bool {
         return doInLock { () -> Bool in
-            return self._errorContainer ? true : false
+            return self._error ? true : false
         }
     }
 

                if let resultTask = result as? HNTask {
                    resultTask.continueWith { context in
                        // TODO: cancel?
                        let prevTask = context as HNTask
                        task.complete(result: prevTask.result, errorContainer: prevTask.errorContainer)
                        return nil
                    }
                } else {
                    task.complete(result: result, errorContainer: self.errorContainer)
                }
            }
        }


protocol HNTaskContext {
    var result: Any? { get }
    var error: HNTaskError? { get }
    
    func isError() -> Bool
}

protocol HNTaskError {
}

class HNTask : HNTaskContext {

    let _lock = NSObject()
    var _completed: Bool = false
    var _result: Any? = nil
    var _error: HNTaskError? = nil
    var _continuations: (() -> Void)[] = []

    /// create an uncompleted task
