     }
     
     private func asDictionary() throws -> [String:JSONValue] {
+        try throwIfError()
         guard let objectDictionary = self.wrapped as? [String:AnyObject] else {
             throw JSONError(.IncompatibleType(typename: "dictionary"), json: self)
         }
         return objectDictionary.transform({ JSONValue($0) })
+    }
+    
+    private func throwIfError() throws {
+        if let error = self.error {
+            throw error
+        }
     }
 }
 

    /// Throws a `JSONError` if the receiver does not wrap a dictionary or if the given key does
    /// not exist in the dictionary.
    public func sub(key: String) throws -> JSONValue {
        guard let value = try self.asDictionary()[key] else {
            throw JSONError(.MissingKey(key: key), json: self)
        }

    /// Throws a `JSONError` if the receiver does not wrap a value that can be converted into  an
    /// array of the desired type.
    public func decode<T: JSONDecodable>() throws -> [T] {
        try throwIfError()
        return try self.asArray().map(T.decode)
    }
}
