node-oauth icon indicating copy to clipboard operation
node-oauth copied to clipboard

Errors aren't Errors

Open 1j01 opened this issue 9 years ago • 2 comments

There are two open pull requests for this: https://github.com/ciaranj/node-oauth/pull/84 and https://github.com/ciaranj/node-oauth/pull/155

I've ended up working around this like so:

handleError = (err, next)->
    # https://github.com/ciaranj/node-oauth/issues/250
    if typeof err is "object" and not (err instanceof Error)
        error = new Error JSON.stringify err
        error[k] = v for k, v of err
        try error[k] = v for k, v of qs.parse err.data
        next error
    else
        next err

1j01 avatar May 05 '15 17:05 1j01

I have written a module that acts as a solution for this problem called node-oauth-error. It essentially takes in the error objects from oauth and converts them into actual Error objects.

radiovisual avatar Apr 27 '16 11:04 radiovisual

+1

popomore avatar Jun 27 '16 16:06 popomore