javascript - What is the error in .catch inside webcam.js file -
in application using webcam. access used webcam.js (https://pixlcore.com/). when opened in eclipse shows error as:syntax error on token "catch", identifier expected
. little code snippet:
var self = this; this.mediadevices.getusermedia({ "audio": false, "video": this.params.constraints || { mandatory: { minwidth: this.params.dest_width, minheight: this.params.dest_height } } }) .then( function(stream) { // got access, attach stream video video.src = window.url.createobjecturl( stream ) || stream; self.stream = stream; self.loaded = true; self.live = true; self.dispatch('load'); self.dispatch('live'); self.flip(); }) .catch( function(err) { //here shows error return self.dispatch('error', "could not access webcam: " + err.name + ": " + err.message, err); });
what reason , how resolve it?
the problem apparently catch
reserved keyword, , code-checker thinks error. however, code checker mistaken, , catch
valid method call. is, unless older version if ie.
in older versions of ie, code fail because had issue assumed catch
outside of try
/catch
invalid. believe issue fixed in either ie9 or ie10, not sure.
anyhow, can work around issue both old ie , other things general issue using catch
in string bracket property access:
// ... .then( function(stream) { // ... }) ['catch']( function(err) { // ... });