Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-101298

Extending the Error class errors when trying to overwrite the `name` property

    XMLWordPrintable

Details

    • macOS
    • b6cf0672e6 (qt/qtdeclarative/dev) b6cf0672e6 (qt/tqtc-qtdeclarative/dev)

    Description

      Example:

      class MyError extends Error {
          constructor() {
              super();
              this.name = "MyError";
          }
      }
      
      // Throws a TypeError
      const e = new MyError();

      If I wrap the `this.name` on a `try/catch` block this works (of course, `name` is not set).

      I think this is something specific on the Error implementation, because this does not throw:

      class A {
          constructor() {
              this.name = "A";
          }
      }
      
      class B extends A {
          constructor() {
              super();
              this.name = "B";
          }
      }
      
      // Does not throw
      const e = new B();

       

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              ulherman Ulf Hermann
              brizental Beatriz Rizental
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes