catch: function()

in public/dexie.js [860:877]


    catch: function (onRejected) {
      if (arguments.length === 1) return this.then(null, onRejected);
      // First argument is the Error type to catch
      var type = arguments[0],
        handler = arguments[1];
      return typeof type === "function"
        ? this.then(null, function (err) {
            // Catching errors by its constructor type (similar to java / c++ / c#)
            // Sample: promise.catch(TypeError, function (e) { ... });
            return err instanceof type ? handler(err) : PromiseReject(err);
          })
        : this.then(null, function (err) {
            // Catching errors by the error.name property. Makes sense for indexedDB where error type
            // is always DOMError but where e.name tells the actual error type.
            // Sample: promise.catch('ConstraintError', function (e) { ... });
            return err && err.name === type ? handler(err) : PromiseReject(err);
          });
    },