Ignore:
Timestamp:
May 23, 2008, 7:23:23 AM (17 years ago)
Author:
[email protected]
Message:

SQUIRRELFISH: JavaScript error messages are missing informative text

Reviewed by Anders

Partial fix.
Tidy up error messages, makes a couple of them provide slightly more info.
Inexplicably leads to a 1% SunSpider Progression.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/VM/ExceptionHelpers.cpp

    r33979 r34075  
    4848JSValue* createError(ExecState* exec, ErrorType e, const char* msg)
    4949{
    50     return Error::create(exec, e, msg, -1, -1, 0); // lineNo(), currentSourceId(exec), currentSourceURL(exec)
     50    return Error::create(exec, e, msg, -1, -1, 0);
    5151}
    5252
     
    5555    UString message = msg;
    5656    substitute(message, label.ustring());
    57     return Error::create(exec, e, message, -1, -1, 0); // lineNo(), currentSourceId(exec), currentSourceURL(exec)
     57    return Error::create(exec, e, message, -1, -1, 0);
    5858}
    5959
     
    6464    if (expr)
    6565        substitute(message, expr->toString());
    66     else
    67         substitute(message, "<<no string for expression>>");
    68     return Error::create(exec, e, message, -1, -1, 0); //, lineNo(), currentSourceId(exec), currentSourceURL(exec));
     66    return Error::create(exec, e, message, -1, -1, 0);
     67}
     68
     69JSValue* createError(ExecState* exec, ErrorType e, const char* msg, JSValue* v)
     70{
     71    UString message = msg;
     72    substitute(message, v->toString(exec));
     73    return Error::create(exec, e, message, -1, -1, 0);
    6974}
    7075
     
    7883    return createError(exec, ReferenceError, "Can't find variable: %s", ident);
    7984}
    80 
    81 JSValue* createNotAnObjectError(ExecState* exec, JSValue* value, Node* expr)
     85   
     86JSValue* createInvalidParamError(ExecState* exec, const char* op, JSValue* v)
    8287{
    83     return createError(exec, TypeError, "Value %s (result of expression %s) is not an object.", value, expr);
     88    UString message = "'%s' is not a valid argument for '%s'";
     89    substitute(message,  v->toString(exec));
     90    substitute(message, op);
     91    return Error::create(exec, TypeError, message, -1, -1, 0);
    8492}
    8593
    8694JSValue* createNotAConstructorError(ExecState* exec, JSValue* value, Node* expr)
    8795{
    88     if (!value->isObject())
    89         return createNotAnObjectError(exec, value, expr);
    90     return createError(exec, TypeError, "Value %s (result of expression %s) is not a constructor. Cannot be used with new.", value, expr);
     96    if (expr)
     97        return createError(exec, TypeError, "Value %s (result of expression %s) is not a constructor. Cannot be used with new.", value, expr);
     98    return createError(exec, TypeError, "Value %s is not a constructor. Cannot be used with new.", value);
    9199}
    92100
    93101JSValue* createNotAFunctionError(ExecState* exec, JSValue* value, Node* expr)
    94102{
    95     if (!value->isObject())
    96         return createNotAnObjectError(exec, value, expr);
    97     return createError(exec, TypeError, "Value %s (result of expression %s) does not allow function calls.", value, expr);
     103    if (expr)
     104        return createError(exec, TypeError, "Value %s (result of expression %s) does not allow function calls.", value, expr);
     105    return createError(exec, TypeError, "Value %s does not allow function calls.", value);
    98106}
    99107
Note: See TracChangeset for help on using the changeset viewer.