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

Navigator API errors are being rethrown as generic errors #1804

Closed
4 tasks done
Nanosync opened this issue Nov 18, 2021 · 4 comments
Closed
4 tasks done

Navigator API errors are being rethrown as generic errors #1804

Nanosync opened this issue Nov 18, 2021 · 4 comments
Labels
device Audio and Video device setup. Failure at getUserMedia stream

Comments

@Nanosync
Copy link

What happened and what did you expect to happen?

We are currently catching error names and handling them by a switch case when calling functions listVideoInputDevices, listAudioInputDevices, chooseVideoInputDevice, chooseAudioInputDevice. However, the chime JS sdk rethrows errors leading to generic errors, although the error.message property is preserved. In the handleGetUserMediaError function, the base error GetUserMediaError doesn't preserve the original error.name property.

Have you reviewed our existing documentation?

Reproduction steps

Disable browser audio/video permissions then call any of the listed functions above. The functions that throw GetUserMediaError or a subclass of it has the error.name property Error although the original error name was more specific.

Amazon Chime SDK for JavaScript version

2.21.0

What browsers are you seeing the problem on?

Chrome

Browser version

95.0.4638.69

Meeting and Attendee ID Information.

No response

Browser console logs

n/a

@ltrung
Copy link
Contributor

ltrung commented Nov 20, 2021

I created PR #1815 to address this issue but for now you can check the error name via error.cause.name.

catch (error) {
  if (error instanceof GetUserMediaError) {
    // Use error.cause?.name to access an Error name and error.cause?.message to access the original error messasge.
  }
}

@ltrung ltrung added the device Audio and Video device setup. Failure at getUserMedia stream label Nov 20, 2021
@ltrung
Copy link
Contributor

ltrung commented Nov 24, 2021

@Nanosync Would the PR #1815 solve your use case? We will return the class name instead of the generic Error name?

@ltrung
Copy link
Contributor

ltrung commented Nov 24, 2021

PR #1815 has been merged so close this.

@ltrung ltrung closed this as completed Nov 24, 2021
@Nanosync
Copy link
Author

Hi @ltrung, yes, it will solve the issue. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
device Audio and Video device setup. Failure at getUserMedia stream
Projects
None yet
Development

No branches or pull requests

2 participants