Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Error class to give more specific errors #3

Open
Lyra-B opened this issue Jun 25, 2021 · 3 comments
Open

Update Error class to give more specific errors #3

Lyra-B opened this issue Jun 25, 2021 · 3 comments
Labels
enhancement New feature or request jira added

Comments

@Lyra-B
Copy link

Lyra-B commented Jun 25, 2021

My team is using twilio-client.js in our telephony app and we are experiencing the following issue. When a twilio networking error occurs we do not have enough information to handle it properly. The code that is relevant to this issue is here.
This error is too generic for us to handle specifically and we are looking for advice on how to move forward.

We noticed  that twilio-voice.js is the next version for this library and according to this it contains much more detailed information about errors, however this particular error class remains as generic as in twilio-client.js

  • Could the Error class be changed to something we can catch and recognise as a twilio request error?
@Lyra-B Lyra-B added the enhancement New feature or request label Jun 25, 2021
@Lyra-B Lyra-B changed the title [FEATURE] Update Error class to give more specific errors Jun 25, 2021
@ryan-rowland
Copy link
Contributor

Hi Lyra,
I apologize for the delayed response here and thanks for submitting this issue. In this case, we are passing back the exact error that we get from the request. The line you linked to could be getting called from multiple places; could you go into more detail on the error(s) you're receiving and how you're receiving them?

@ryan-rowland ryan-rowland added the question Further information is requested label Jul 14, 2021
@doryphores
Copy link

The issue here is that we use Airbrake to report JavaScript errors. The airbrake JS SDK registers a global unhandledrejection listener that reports all uncaught promise rejections. This is resulting in any error coming from this request module being reported to our airbrake account because of the following:

The request module in question is used by EventPublisher which returns a promise that is rejected when the xhr request fails. Neither EventPublisher or Call which uses it handles the rejection so these errors are being caught by airbrake's unhandledrejection listener. The errors are simple Error classes so we can't even filter them out (if they were TwilioError instances with a specific code, we could do this).

I'm not sure what the right approach is here. I can see why you may not want to wrap these as TwilioError as they're xhr request errors. But you may want to stop rejecting the promise when they fail (delete this line?). The error is emitted as an error event anyway and I can see that these are being logged as a warning:

this._publisher.on('error', (error: Error) => {
this._log.warn('Cannot connect to insights.', error);
});
}

@ryan-rowland
Copy link
Contributor

Thanks @doryphores, I see what you mean. I agree that we should either catch these rejections in the SDK (if we plan to do something about them) or change this method to return void, as you've suggested. I will create an internal ticket for this, and I'll update this ticket once we've addressed the issue.

@charliesantos charliesantos added jira added and removed question Further information is requested labels Mar 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request jira added
Projects
None yet
Development

No branches or pull requests

4 participants