         }
     }
     
-    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
         }
     }
 


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

class HNTask : HNTaskContext {

    struct ErrorContainer {
        let value: Any?
        init(value: Any?) {
            self.value = value
        }
    }
    
    let _lock = NSObject()
    var _completed: Bool = false
    var _result: Any? = nil
    var _errorContainer: ErrorContainer? = nil
    var _continuations: (() -> Void)[] = []

    /// create an uncompleted task


// suppose it is used in this way

//extension NSError: HNTaskError { }
//
//func foo() {
//    let task = HNTask()
//    task.resolve(nil)
