Index: src/factory.h |
diff --git a/src/factory.h b/src/factory.h |
index 96fa74da8ffd064e99201fb4ae4619cb3bfa6dec..57f537effd1970701ad81ea5a29c8973c484c1ad 100644 |
--- a/src/factory.h |
+++ b/src/factory.h |
@@ -546,11 +546,6 @@ class Factory final { |
Handle<Code> CopyCode(Handle<Code> code, Vector<byte> reloc_info); |
// Interface for creating error objects. |
- |
- Handle<Object> NewError(const char* maker, const char* message, |
- Handle<JSArray> args); |
- Handle<String> EmergencyNewError(const char* message, Handle<JSArray> args); |
- |
Handle<Object> NewError(Handle<JSFunction> constructor, |
Handle<String> message); |
@@ -558,41 +553,28 @@ class Factory final { |
return NewRangeError(MessageTemplate::kInvalidStringLength); |
} |
- Handle<Object> NewError(const char* maker, |
+ Handle<Object> NewError(Handle<JSFunction> constructor, |
MessageTemplate::Template template_index, |
Handle<Object> arg0 = Handle<Object>(), |
Handle<Object> arg1 = Handle<Object>(), |
Handle<Object> arg2 = Handle<Object>()); |
- Handle<Object> NewError(MessageTemplate::Template template_index, |
- Handle<Object> arg0 = Handle<Object>(), |
- Handle<Object> arg1 = Handle<Object>(), |
- Handle<Object> arg2 = Handle<Object>()); |
+#define DEFINE_ERROR(NAME, name) \ |
+ Handle<Object> New##NAME(MessageTemplate::Template template_index, \ |
+ Handle<Object> arg0 = Handle<Object>(), \ |
+ Handle<Object> arg1 = Handle<Object>(), \ |
+ Handle<Object> arg2 = Handle<Object>()) { \ |
+ return NewError(isolate()->name##_function(), template_index, arg0, arg1, \ |
+ arg2); \ |
+ } |
- Handle<Object> NewTypeError(MessageTemplate::Template template_index, |
- Handle<Object> arg0 = Handle<Object>(), |
- Handle<Object> arg1 = Handle<Object>(), |
- Handle<Object> arg2 = Handle<Object>()); |
- |
- Handle<Object> NewSyntaxError(MessageTemplate::Template template_index, |
- Handle<Object> arg0 = Handle<Object>(), |
- Handle<Object> arg1 = Handle<Object>(), |
- Handle<Object> arg2 = Handle<Object>()); |
- |
- Handle<Object> NewReferenceError(MessageTemplate::Template template_index, |
- Handle<Object> arg0 = Handle<Object>(), |
- Handle<Object> arg1 = Handle<Object>(), |
- Handle<Object> arg2 = Handle<Object>()); |
- |
- Handle<Object> NewRangeError(MessageTemplate::Template template_index, |
- Handle<Object> arg0 = Handle<Object>(), |
- Handle<Object> arg1 = Handle<Object>(), |
- Handle<Object> arg2 = Handle<Object>()); |
- |
- Handle<Object> NewEvalError(MessageTemplate::Template template_index, |
- Handle<Object> arg0 = Handle<Object>(), |
- Handle<Object> arg1 = Handle<Object>(), |
- Handle<Object> arg2 = Handle<Object>()); |
+ DEFINE_ERROR(Error, error) |
+ DEFINE_ERROR(EvalError, eval_error) |
+ DEFINE_ERROR(RangeError, range_error) |
+ DEFINE_ERROR(ReferenceError, reference_error) |
+ DEFINE_ERROR(SyntaxError, syntax_error) |
+ DEFINE_ERROR(TypeError, type_error) |
+#undef DEFINE_ERROR |
Handle<String> NumberToString(Handle<Object> number, |
bool check_number_string_cache = true); |