code: function rename(cls, name) {
      try {
        Object.defineProperty(cls, "name", { value: name });
      }
      catch (ex) {
        // Trying to defineProperty on `name` fails on Safari with a TypeError.
        if (!(ex instanceof TypeError)) {
          throw ex;
        }
      }
      cls.prototype.name = name;
    }
docs: Utility function for classes that are derived from Error. The prototype name is initially set to some generic value which is not particularly useful. This fixes the problem. We have to pass an explicit string through `name` because on some platforms we cannot count on `cls.name`.