opentok / opentok-node

OpenTok Server SDK for node.js
MIT License
164 stars 167 forks source link

Swallowing meaningful errors from rest API #166

Open synthmusic opened 7 years ago

synthmusic commented 7 years ago
... else {
    callback(new errors.RequestError('Unexpected response from OpenTok'));
}

is used many times in archiving.js, which will obfuscate what may be an actual usable error message from the openTok rest api. I'm thinking to submit an update, but of course checking first if this goes against some strategy in place on purpose. Perhaps a new error type in errors.js? Problem being the objects only take messages and not the error code, so might need to "stringify" the code in the message

CatGuardian commented 6 years ago

I was just having a similar thought.

If you are going to to do this then please add a 'statusCode' parameter to the error objects. And then assign the HTTP status response code to all of the errors in this system.

https://tokbox.com/developer/rest/#stop_archive

The problem I'm running into is that I want to know that a 409 is thrown during stopArchiving instead of having to rely on a string from the opentok API.