Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: src/d8.cc

Issue 10911305: Replace r12503. Explicitly check toString() for exception in d8's print(). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/api.cc ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 return val; 193 return val;
194 } 194 }
195 195
196 196
197 Handle<Value> Shell::Write(const Arguments& args) { 197 Handle<Value> Shell::Write(const Arguments& args) {
198 for (int i = 0; i < args.Length(); i++) { 198 for (int i = 0; i < args.Length(); i++) {
199 HandleScope handle_scope; 199 HandleScope handle_scope;
200 if (i != 0) { 200 if (i != 0) {
201 printf(" "); 201 printf(" ");
202 } 202 }
203 v8::String::Utf8Value str(args[i]); 203
204 // Explicitly catch potential exceptions in toString().
205 v8::TryCatch try_catch;
206 Handle<String> str_obj = args[i]->ToString();
207 if (try_catch.HasCaught()) return try_catch.ReThrow();
208
209 v8::String::Utf8Value str(str_obj);
204 int n = static_cast<int>(fwrite(*str, sizeof(**str), str.length(), stdout)); 210 int n = static_cast<int>(fwrite(*str, sizeof(**str), str.length(), stdout));
205 if (n != str.length()) { 211 if (n != str.length()) {
206 printf("Error in fwrite\n"); 212 printf("Error in fwrite\n");
207 Exit(1); 213 Exit(1);
208 } 214 }
209 } 215 }
210 return Undefined(); 216 return Undefined();
211 } 217 }
212 218
213 219
(...skipping 1685 matching lines...) Expand 10 before | Expand all | Expand 10 after
1899 } 1905 }
1900 1906
1901 } // namespace v8 1907 } // namespace v8
1902 1908
1903 1909
1904 #ifndef GOOGLE3 1910 #ifndef GOOGLE3
1905 int main(int argc, char* argv[]) { 1911 int main(int argc, char* argv[]) {
1906 return v8::Shell::Main(argc, argv); 1912 return v8::Shell::Main(argc, argv);
1907 } 1913 }
1908 #endif 1914 #endif
OLDNEW
« no previous file with comments | « src/api.cc ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698