Changeset 35911 in webkit for trunk/JavaScriptCore/kjs/Shell.cpp


Ignore:
Timestamp:
Aug 24, 2008, 9:08:01 PM (17 years ago)
Author:
[email protected]
Message:

2008-08-24 Cameron Zwarich <[email protected]>

Reviewed by Oliver Hunt.

Bug 20093: JSC shell does not clear exceptions after it executes toString on an expression
<https://bugs.webkit.org/show_bug.cgi?id=20093>

Clear exceptions after evaluating any code in the JSC shell. We do not
report exceptions that are caused by calling toString on the final
valued, but at least we avoid incorrect behaviour.

Also, print any exceptions that occurred while evaluating code at the
interactive prompt, not just while evaluating code from a file.

  • kjs/Shell.cpp: (runWithScripts): (runInteractive):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/Shell.cpp

    r35853 r35911  
    351351            success = success && completion.complType() != Throw;
    352352            if (dump) {
    353                 if (success)
     353                if (completion.complType() == Throw)
     354                    printf("Exception: %s\n", completion.value()->toString(globalObject->globalExec()).ascii());
     355                else
    354356                    printf("End: %s\n", completion.value()->toString(globalObject->globalExec()).ascii());
    355                 else
    356                     printf("Exception: %s\n", completion.value()->toString(globalObject->globalExec()).ascii());
    357357            }
     358
     359            globalObject->globalExec()->clearException();
    358360
    359361#if ENABLE(SAMPLING_TOOL)
     
    391393        Completion completion = Interpreter::evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), interpreterName, 1, line.data());
    392394#endif
    393         if (completion.isValueCompletion())
     395        if (completion.complType() == Throw)
     396            printf("Exception: %s\n", completion.value()->toString(globalObject->globalExec()).ascii());
     397        else
    394398            printf("%s\n", completion.value()->toString(globalObject->globalExec()).UTF8String().c_str());
     399
     400        globalObject->globalExec()->clearException();
    395401    }
    396402    printf("\n");
Note: See TracChangeset for help on using the changeset viewer.