OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 duplicate_regexp_flag: ["Duplicate RegExp flag ", "%0"], | 200 duplicate_regexp_flag: ["Duplicate RegExp flag ", "%0"], |
201 invalid_regexp: ["Invalid RegExp pattern /", "%0", "/"], | 201 invalid_regexp: ["Invalid RegExp pattern /", "%0", "/"], |
202 illegal_break: ["Illegal break statement"], | 202 illegal_break: ["Illegal break statement"], |
203 illegal_continue: ["Illegal continue statement"], | 203 illegal_continue: ["Illegal continue statement"], |
204 illegal_return: ["Illegal return statement"], | 204 illegal_return: ["Illegal return statement"], |
205 error_loading_debugger: ["Error loading debugger"], | 205 error_loading_debugger: ["Error loading debugger"], |
206 no_input_to_regexp: ["No input to ", "%0"], | 206 no_input_to_regexp: ["No input to ", "%0"], |
207 invalid_json: ["String '", "%0", "' is not valid JSON"], | 207 invalid_json: ["String '", "%0", "' is not valid JSON"], |
208 circular_structure: ["Converting circular structure to JSON"], | 208 circular_structure: ["Converting circular structure to JSON"], |
209 obj_ctor_property_non_object: ["Object.", "%0", " called on non-object"], | 209 obj_ctor_property_non_object: ["Object.", "%0", " called on non-object"], |
210 called_on_null_or_undefined: ["%0", " called on null or undefined"], | |
211 array_indexof_not_defined: ["Array.getIndexOf: Argument undefined"], | 210 array_indexof_not_defined: ["Array.getIndexOf: Argument undefined"], |
212 object_not_extensible: ["Can't add property ", "%0", ", object is n
ot extensible"], | 211 object_not_extensible: ["Can't add property ", "%0", ", object is n
ot extensible"], |
213 illegal_access: ["Illegal access"], | 212 illegal_access: ["Illegal access"], |
214 invalid_preparser_data: ["Invalid preparser data for function ", "%0
"], | 213 invalid_preparser_data: ["Invalid preparser data for function ", "%0
"], |
215 strict_mode_with: ["Strict mode code may not include a with st
atement"], | 214 strict_mode_with: ["Strict mode code may not include a with st
atement"], |
216 strict_catch_variable: ["Catch variable may not be eval or argument
s in strict mode"], | 215 strict_catch_variable: ["Catch variable may not be eval or argument
s in strict mode"], |
217 too_many_parameters: ["Too many parameters in function definition
"], | 216 too_many_parameters: ["Too many parameters in function definition
"], |
218 strict_param_name: ["Parameter name eval or arguments is not al
lowed in strict mode"], | 217 strict_param_name: ["Parameter name eval or arguments is not al
lowed in strict mode"], |
219 strict_param_dupe: ["Strict mode function may not have duplicat
e parameter names"], | 218 strict_param_dupe: ["Strict mode function may not have duplicat
e parameter names"], |
220 strict_var_name: ["Variable name may not be eval or arguments
in strict mode"], | 219 strict_var_name: ["Variable name may not be eval or arguments
in strict mode"], |
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1064 var message = %_CallFunction(this, "message", ObjectHasOwnProperty) | 1063 var message = %_CallFunction(this, "message", ObjectHasOwnProperty) |
1065 ? (": " + this.message) | 1064 ? (": " + this.message) |
1066 : ""; | 1065 : ""; |
1067 return this.name + message; | 1066 return this.name + message; |
1068 } finally { | 1067 } finally { |
1069 visited_errors.length = visited_errors.length - 1; | 1068 visited_errors.length = visited_errors.length - 1; |
1070 } | 1069 } |
1071 } | 1070 } |
1072 | 1071 |
1073 function errorToString() { | 1072 function errorToString() { |
1074 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { | |
1075 throw MakeTypeError("called_on_null_or_undefined", | |
1076 ["Error.prototype.toString"]); | |
1077 } | |
1078 // This helper function is needed because access to properties on | 1073 // This helper function is needed because access to properties on |
1079 // the builtins object do not work inside of a catch clause. | 1074 // the builtins object do not work inside of a catch clause. |
1080 function isCyclicErrorMarker(o) { return o === cyclic_error_marker; } | 1075 function isCyclicErrorMarker(o) { return o === cyclic_error_marker; } |
1081 | 1076 |
1082 try { | 1077 try { |
1083 return %_CallFunction(this, errorToStringDetectCycle); | 1078 return %_CallFunction(this, errorToStringDetectCycle); |
1084 } catch(e) { | 1079 } catch(e) { |
1085 // If this error message was encountered already return the empty | 1080 // If this error message was encountered already return the empty |
1086 // string for it instead of recursively formatting it. | 1081 // string for it instead of recursively formatting it. |
1087 if (isCyclicErrorMarker(e)) return ''; | 1082 if (isCyclicErrorMarker(e)) return ''; |
1088 else throw e; | 1083 else throw e; |
1089 } | 1084 } |
1090 } | 1085 } |
1091 | 1086 |
1092 | 1087 |
1093 InstallFunctions($Error.prototype, DONT_ENUM, ['toString', errorToString]); | 1088 InstallFunctions($Error.prototype, DONT_ENUM, ['toString', errorToString]); |
1094 | 1089 |
1095 // Boilerplate for exceptions for stack overflows. Used from | 1090 // Boilerplate for exceptions for stack overflows. Used from |
1096 // Isolate::StackOverflow(). | 1091 // Isolate::StackOverflow(). |
1097 const kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []); | 1092 const kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []); |
OLD | NEW |