-const char* expressionBeginOffsetPropertyName = "expressionBeginOffset";
-const char* expressionCaretOffsetPropertyName = "expressionCaretOffset";
-const char* expressionEndOffsetPropertyName = "expressionEndOffset";
-
-JSObject* Error::create(ExecState* exec, ErrorType type, const UString& message, int lineNumber, intptr_t sourceID, const UString& sourceURL)
-{
- JSObject* constructor;
- const char* name;
- switch (type) {
- case EvalError:
- constructor = exec->lexicalGlobalObject()->evalErrorConstructor();
- name = "Evaluation error";
- break;
- case RangeError:
- constructor = exec->lexicalGlobalObject()->rangeErrorConstructor();
- name = "Range error";
- break;
- case ReferenceError:
- constructor = exec->lexicalGlobalObject()->referenceErrorConstructor();
- name = "Reference error";
- break;
- case SyntaxError:
- constructor = exec->lexicalGlobalObject()->syntaxErrorConstructor();
- name = "Syntax error";
- break;
- case TypeError:
- constructor = exec->lexicalGlobalObject()->typeErrorConstructor();
- name = "Type error";
- break;
- case URIError:
- constructor = exec->lexicalGlobalObject()->URIErrorConstructor();
- name = "URI error";
- break;
- default:
- constructor = exec->lexicalGlobalObject()->errorConstructor();
- name = "Error";
- break;
- }
-
- MarkedArgumentBuffer args;
- if (message.isEmpty())
- args.append(jsString(exec, name));
- else
- args.append(jsString(exec, message));
- ConstructData constructData;
- ConstructType constructType = constructor->getConstructData(constructData);
- JSObject* error = construct(exec, constructor, constructType, constructData, args);
-
- if (lineNumber != -1)
- error->putWithAttributes(exec, Identifier(exec, "line"), jsNumber(exec, lineNumber), ReadOnly | DontDelete);
- if (sourceID != -1)
- error->putWithAttributes(exec, Identifier(exec, "sourceId"), jsNumber(exec, sourceID), ReadOnly | DontDelete);
+static const char* linePropertyName = "line";
+static const char* sourceURLPropertyName = "sourceURL";
+
+JSObject* createError(JSGlobalObject* globalObject, const UString& message)
+{
+ ASSERT(!message.isEmpty());
+ return ErrorInstance::create(globalObject->globalData(), globalObject->errorStructure(), message);
+}
+
+JSObject* createEvalError(JSGlobalObject* globalObject, const UString& message)
+{
+ ASSERT(!message.isEmpty());
+ return ErrorInstance::create(globalObject->globalData(), globalObject->evalErrorConstructor()->errorStructure(), message);
+}
+
+JSObject* createRangeError(JSGlobalObject* globalObject, const UString& message)
+{
+ ASSERT(!message.isEmpty());
+ return ErrorInstance::create(globalObject->globalData(), globalObject->rangeErrorConstructor()->errorStructure(), message);
+}
+
+JSObject* createReferenceError(JSGlobalObject* globalObject, const UString& message)
+{
+ ASSERT(!message.isEmpty());
+ return ErrorInstance::create(globalObject->globalData(), globalObject->referenceErrorConstructor()->errorStructure(), message);
+}
+
+JSObject* createSyntaxError(JSGlobalObject* globalObject, const UString& message)
+{
+ ASSERT(!message.isEmpty());
+ return ErrorInstance::create(globalObject->globalData(), globalObject->syntaxErrorConstructor()->errorStructure(), message);
+}
+
+JSObject* createTypeError(JSGlobalObject* globalObject, const UString& message)
+{
+ ASSERT(!message.isEmpty());
+ return ErrorInstance::create(globalObject->globalData(), globalObject->typeErrorConstructor()->errorStructure(), message);
+}
+
+JSObject* createNotEnoughArgumentsError(JSGlobalObject* globalObject)
+{
+ return createTypeError(globalObject, "Not enough arguments");
+}
+
+JSObject* createURIError(JSGlobalObject* globalObject, const UString& message)
+{
+ ASSERT(!message.isEmpty());
+ return ErrorInstance::create(globalObject->globalData(), globalObject->URIErrorConstructor()->errorStructure(), message);
+}
+
+JSObject* createError(ExecState* exec, const UString& message)
+{
+ return createError(exec->lexicalGlobalObject(), message);
+}
+
+JSObject* createEvalError(ExecState* exec, const UString& message)
+{
+ return createEvalError(exec->lexicalGlobalObject(), message);
+}
+
+JSObject* createRangeError(ExecState* exec, const UString& message)
+{
+ return createRangeError(exec->lexicalGlobalObject(), message);
+}
+
+JSObject* createReferenceError(ExecState* exec, const UString& message)
+{
+ return createReferenceError(exec->lexicalGlobalObject(), message);
+}
+
+JSObject* createSyntaxError(ExecState* exec, const UString& message)
+{
+ return createSyntaxError(exec->lexicalGlobalObject(), message);
+}
+
+JSObject* createTypeError(ExecState* exec, const UString& message)
+{
+ return createTypeError(exec->lexicalGlobalObject(), message);
+}
+
+JSObject* createNotEnoughArgumentsError(ExecState* exec)
+{
+ return createNotEnoughArgumentsError(exec->lexicalGlobalObject());
+}
+
+JSObject* createURIError(ExecState* exec, const UString& message)
+{
+ return createURIError(exec->lexicalGlobalObject(), message);
+}
+
+JSObject* addErrorInfo(CallFrame* callFrame, JSObject* error, int line, const SourceCode& source)
+{
+ JSGlobalData* globalData = &callFrame->globalData();
+ const UString& sourceURL = source.provider()->url();
+
+ if (line != -1)
+ error->putDirect(*globalData, Identifier(globalData, linePropertyName), jsNumber(line), ReadOnly | DontDelete);