meetecho / janus-gateway

Janus WebRTC Server
https://janus.conf.meetecho.com
GNU General Public License v3.0
8.24k stars 2.48k forks source link

Add error codes #1025

Closed sanbornhilland closed 4 years ago

sanbornhilland commented 7 years ago

In most places error callbacks receive only descriptions of the error that occurred. In order to map errors then, we need to do string matching which is a pretty brittle approach. It would be useful to add error objects with stable error codes such as this:

{
    code: 1, 

    // The content of the current error strings
    description: 'This is an error', 

    // In cases where we have an error object (e.g. network error)
    // this can be attached for more info.
    rootError: {}
}

I think this would probably be sufficient to solve the issue without adding a whole lot of complexity.

lminiero commented 7 years ago

Sounds like a good idea! We just need to make sure this is well discussed, when available, as it would break applications using janus.js as it is now (e.g., assuming strings where there wouldn't be anymore).

Bhlowe commented 6 years ago

If in debug mode, adding LINE and FILE to the json output would be nice too! Tried to hack that in as a feature but it was too nasty to brag about.. but if you're redoing the error handling, I thought I'd mention it. Helpful when trying to figure out where in the code error messages are coming from.

manifest commented 5 years ago

I just want to mention, that there is an RFC 7807 describing error format.

lminiero commented 4 years ago

A long time passed and we're not planning to work on this, so I'll close.