Throwing object with error prototype causes error proto to be caught

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P3
    • 9
    • Affects Version/s: 8u20
    • Component/s: core-libs
    • None
    • b39
    • generic
    • generic

        The code to use the existing exception in ECMAException.create will use an inherited nashornException property, causing catch clauses to be executed with the prototype object instead of the actual thrown object.

        Code to reproduce:

        function CustomError() {}
        CustomError.prototype = new Error();

        var c = new CustomError();

        try {
            throw c;
        } catch (e) {
            print(e === c);
            print(e === CustomError.prototype);
        }

              Assignee:
              Hannes Wallnoefer
              Reporter:
              Hannes Wallnoefer
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: