Index: src/messages.cc |
diff --git a/src/messages.cc b/src/messages.cc |
index c7a44761a49a58a9d43ca2bdad640566f4e1b8a8..4e0c45f0f1992ca70ed191bfe63c6a4fac4bed7c 100644 |
--- a/src/messages.cc |
+++ b/src/messages.cc |
@@ -322,23 +322,29 @@ Handle<String> MessageTemplate::FormatMessage(Isolate* isolate, |
} |
-MaybeHandle<String> MessageTemplate::FormatMessage(int template_index, |
- Handle<String> arg0, |
- Handle<String> arg1, |
- Handle<String> arg2) { |
- Isolate* isolate = arg0->GetIsolate(); |
- const char* template_string; |
+const char* MessageTemplate::TemplateString(int template_index) { |
switch (template_index) { |
-#define CASE(NAME, STRING) \ |
- case k##NAME: \ |
- template_string = STRING; \ |
- break; |
+#define CASE(NAME, STRING) \ |
+ case k##NAME: \ |
+ return STRING; |
MESSAGE_TEMPLATES(CASE) |
#undef CASE |
case kLastMessage: |
default: |
- isolate->ThrowIllegalOperation(); |
- return MaybeHandle<String>(); |
+ return NULL; |
+ } |
+} |
+ |
+ |
+MaybeHandle<String> MessageTemplate::FormatMessage(int template_index, |
+ Handle<String> arg0, |
+ Handle<String> arg1, |
+ Handle<String> arg2) { |
+ Isolate* isolate = arg0->GetIsolate(); |
+ const char* template_string = TemplateString(template_index); |
+ if (template_string == NULL) { |
+ isolate->ThrowIllegalOperation(); |
+ return MaybeHandle<String>(); |
} |
IncrementalStringBuilder builder(isolate); |