sintaxi / dbox

NodeJS SDK for Dropbox API (THIS LIBRARY IS OBSOLETE!!)
514 stars 91 forks source link

Exception thrown when Dropbox is down #56

Open scttnlsn opened 11 years ago

scttnlsn commented 11 years ago

Got a JSON parse error thrown when making a call to the files_put endpoint while the Dropbox service was down:

SyntaxError: Unexpected token <
    at Object.parse (native)
    at Request.exports.app.client.put [as _callback] (./node_modules/dbox/dbox.js:142:57)
    at Request.init.self.callback (./node_modules/dbox/node_modules/request/main.js:119:22)
    at Request.<anonymous> (./node_modules/dbox/node_modules/request/main.js:525:16)
    at Request.EventEmitter.emit (events.js:88:17)
    at IncomingMessage.Request.start.self.req.self.httpModule.request.buffer (./node_modules/dbox/node_modules/request/main.js:484:14)
    at IncomingMessage.EventEmitter.emit (events.js:115:20)
    at IncomingMessage._emitEnd (http.js:366:10)
    at HTTPParser.parserOnMessageComplete [as onMessageComplete] (http.js:149:23)
    at CleartextStream.socketOnData [as ondata] (http.js:1366:20)

Perhaps if the response has status code >= 500 the function should return an error to the callback?

scttnlsn commented 11 years ago

Nevermind, looks like errors are never returned. It shouldn't proceed to parse the body though.

jeremycondon commented 11 years ago

Issue 57 should resolve this. I must have done the pull request wrong.