               callback = next
             else if (!errback)
               errback = next
-
           else if (type == 'object' && !params)
             params = next
           else
-            throw new Error("Invalid argument passed to Hull.api(): " + next)
+            throw new TypeError("Invalid argument passed to Hull.api(): " + next)
 
           next = args.shift()
 

        params ?= {}

        callback ?= ->
        errback  ?= (err, data)-> console.error('Uncaught error: ', err, data)

        ret = [{ path: path, method: method, params: params }, callback, errback]


        next = args.shift()

        if (typeof path != 'string')
          throw new TypeError("Invalid path passed to Hull.api() : " + JSON.stringify(path));

        while (next)
          type = typeof next
