exports.Response = function(response) {
    var sendUserError = function(message) {
        response.send(message, { 'Content-Type': 'text/plain' }, 400)
    }
    return {
        response: function() {
            return response
        },
        handleErrorAsUsersFault: function(error) {
            if (error) {
                sendUserError(error.message)
                return true
            }
        }
    }
}

exports.request = function(args, callback) {
    require('request')(args, function(error, response, body) {
        if (error) callback(error)
        if (response.statusCode >= 400) return callback(new Error("Error " + _res.statusCode))
        callback(null, response, body)
    })
}

exports.download = function(url, callback) {
    this.request({ url: url, encoding: 'binary' }, function(error, response, body) {
        if (error) return callback(error)
        require('temp').open('download', function(error, file) {
            require('fs').write(file.fd, body, null, 'binary', function(error) {
                if (error) return callback(error)
                callback(null, file.path, response)
            })
        })
    })
}

@@ -459,24 +459,38 @@
 callback) %7B%0A
+    try %7B%0A    
     require(
@@ -540,32 +540,36 @@
 body) %7B%0A        
+    
 if (error) callb
@@ -583,24 +583,28 @@
 or)%0A        
+   
+ 
 if (response
@@ -678,32 +678,36 @@
 sCode))%0A        
+    
 callback(null, r
@@ -725,18 +725,74 @@
 dy)%0A    
+    %7D)%0A    %7D catch (error) %7B%0A        callback(error)%0A    
 %7D
-)
 %0A%7D%0A%0Aexpo

Handle errors on calling request()