Browse Source

Log error in order to not lose details

dev1
Lyubomir Marinov 9 years ago
parent
commit
1ea561f0ae
1 changed files with 26 additions and 16 deletions
  1. 26
    16
      JitsiTrackErrors.js

+ 26
- 16
JitsiTrackErrors.js View File

@@ -1,3 +1,5 @@
1
+var logger = require("jitsi-meet-logger").getLogger(__filename);
2
+
1 3
 module.exports = {
2 4
     /**
3 5
      * Returns JitsiTrackErrors based on the error object passed by GUM
@@ -5,23 +7,31 @@ module.exports = {
5 7
      * @param {Array} devices Array with the requested devices
6 8
      */
7 9
     parseError: function (error, devices) {
8
-        devices = devices || [];
9
-        if (typeof error == "object" && error.constraintName && error.name
10
-            && (error.name == "ConstraintNotSatisfiedError" ||
11
-            error.name == "OverconstrainedError") &&
12
-            (error.constraintName == "minWidth" ||
13
-            error.constraintName == "maxWidth" ||
14
-            error.constraintName == "minHeight" ||
15
-            error.constraintName == "maxHeight" ||
16
-            error.constraintName == "width" ||
17
-            error.constraintName == "height") &&
18
-            devices.indexOf("video") !== -1) {
19
-                return this.UNSUPPORTED_RESOLUTION;
20
-        } else if(typeof error === "object" && error.type === "jitsiError") {
21
-            return error.errorObject;
22
-        } else {
23
-            return this.GENERAL;
10
+        if (typeof error === "object") {
11
+          var constraintName = error.constraintName;
12
+          var name;
13
+          if (constraintName
14
+                  && (name = error.name)
15
+                  && (name == "ConstraintNotSatisfiedError"
16
+                      || name == "OverconstrainedError")
17
+                  && (constraintName == "minWidth"
18
+                      || constraintName == "maxWidth"
19
+                      || constraintName == "minHeight"
20
+                      || constraintName == "maxHeight"
21
+                      || constraintName == "width"
22
+                      || constraintName == "height")
23
+                  && (devices || []).indexOf("video") !== -1) {
24
+              return this.UNSUPPORTED_RESOLUTION;
25
+          }
26
+          if (error.type === "jitsiError") {
27
+              return error.errorObject;
28
+          }
24 29
         }
30
+        // XXX We're about to lose the details represented by error and devices
31
+        // (because we're about to generalize them to GENERAL). At the very
32
+        // least log the details.
33
+        logger.error('Parsing error into ' + this.GENERAL + ': ' + error);
34
+        return this.GENERAL;
25 35
     },
26 36
     UNSUPPORTED_RESOLUTION: "gum.unsupported_resolution",
27 37
     /**

Loading…
Cancel
Save