[go: nahoru, domu]

Skip to content

Commit

Permalink
Fix error message handling in getusermedia/gum. (#1664)
Browse files Browse the repository at this point in the history
* Fix error message handling in getusermedia/gum.

Currently, when some errors occur in the getusermedia/gum demo,
the error message isn't handled correctly because the constraints object
might not have required properties in some cases. This patch fixes
the error message handling by using the error object directly and
dumping it as a JSON string.
  • Loading branch information
bc-lee committed May 29, 2024
1 parent fba7dc3 commit 9db4d1d
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/content/getusermedia/gum/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ function handleSuccess(stream) {

function handleError(error) {
if (error.name === 'OverconstrainedError') {
const v = constraints.video;
errorMsg(`The resolution ${v.width.exact}x${v.height.exact} px is not supported by your device.`);
errorMsg(`OverconstrainedError: The constraints could not be satisfied by the available devices. Constraints: ${JSON.stringify(constraints)}`);
} else if (error.name === 'NotAllowedError') {
errorMsg('Permissions have not been granted to use your camera and ' +
errorMsg('NotAllowedError: Permissions have not been granted to use your camera and ' +
'microphone, you need to allow the page access to your devices in ' +
'order for the demo to work.');
}
Expand Down

0 comments on commit 9db4d1d

Please sign in to comment.