bnoguchi/everyauth — Issue #95: error parsing XML error from Twitter
Author: RandomEtc
Created: 2011-10-10 21:56:13+00:00
State: open

We've been getting a few errors from the Twitter handler that others should probably be aware of. Without a global error handler* this can crash your app. I think it happens when keys and URLs don't match so we're seeing less of it now and it's hard to trigger on purpose (which is why I'm not sending a patch yet).

Here's the stack trace:

```

[2011-10-06 21:12:47.165] [INFO] console - starting step - getRequestToken

//node_modules/everyauth/lib/modules/twitter.js:35
return new Error(data.data.match(/(.+)<\/error>/)[1]);
^
TypeError: Cannot read property '1' of null
at //node_modules/everyauth/lib/modules/twitter.js:35:61
at //node_modules/everyauth/lib/step.js:97:21
at [object Object].fail (//node_modules/everyauth/lib/promise.js:53:24)
at //node_modules/everyauth/lib/modules/oauth.js:105:18
at //node_modules/oauth/lib/oauth.js:510:17
at passBackControl (//node_modules/oauth/lib/oauth.js:366:13)
at IncomingMessage. (//node_modules/oauth/lib/oauth.js:378:9)
at IncomingMessage.emit (events.js:81:20)
at HTTPParser.onMessageComplete (http.js:133:23)
at CleartextStream.ondata (http.js:1231:22)
process terminated

```

* we added an extra layer of protection against this with:

```
everyauth.everymodule.moduleErrback( function (err, data) {
data.res.send("Internal error on authentication", 500);
});
```

But that's just a workaround, it would be nice to get a meaningful error from the module itself - can anyone figure out what the error looks like before its parsed? :)