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

    }

    func resolve(result: Any?) {
        complete(result: result, error: nil)
    }
    
    func reject(error: HNTaskError?) {
        complete(result: nil, error: error)
    }
    
    // @private
    func complete(#result: Any?, error: HNTaskError?) {
        doInLock { () -> Void in
            if !self._completed {
                self._completed = true
                self._result = result
                self._error = error
            }
            
            // TODO: notify
