bnoguchi/everyauth — Issue #190: foursquare convertErr throws SyntaxError
Author: RandomEtc
Created: 2012-02-23 22:35:02+00:00
State: open

The specific issue I had was caused by mismatching app settings (on my foursquare dev account) and server settings. I needed to update my callback url.

However, the error caused a hard crash:

```
SyntaxError: Unexpected token ILLEGAL
at Object.parse (native)
at /myapp/node_modules/everyauth/lib/modules/foursquare.js:34:23
at /myapp/node_modules/everyauth/lib/step.js:98:21
at [object Object].fail (/myapp/node_modules/everyauth/lib/promise.js:53:24)
at EventEmitter. (/myapp/node_modules/everyauth/lib/modules/oauth2.js:184:11)
at EventEmitter.emit (events.js:81:20)
at EventEmitter._respond (/myapp/node_modules/everyauth/node_modules/restler/lib/restler.js:132:12)
at EventEmitter._fireEvents (/myapp/node_modules/everyauth/node_modules/restler/lib/restler.js:136:52)
at /myapp/node_modules/everyauth/node_modules/restler/lib/restler.js:120:19
at IncomingMessage. (/mya
process terminated
```

I believe the required fix to `foursquare.js` is:

```javascript
.convertErr( function (data) {
return new Error(data.error);
});
```

Instead of:

```javascript
.convertErr( function (data) {
var errMsg = JSON.parse(data.data).meta.errorDetail;
return new Error(errMsg);
});
```

However I'm not sure if there are other errors that use the same callback and take different forms, so I'm posting here to see if anyone knows more?