| 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 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1062 var message = %_CallFunction(this, "message", ObjectHasOwnProperty) | 1062 var message = %_CallFunction(this, "message", ObjectHasOwnProperty) |
| 1063 ? (": " + this.message) | 1063 ? (": " + this.message) |
| 1064 : ""; | 1064 : ""; |
| 1065 return this.name + message; | 1065 return this.name + message; |
| 1066 } finally { | 1066 } finally { |
| 1067 visited_errors.length = visited_errors.length - 1; | 1067 visited_errors.length = visited_errors.length - 1; |
| 1068 } | 1068 } |
| 1069 } | 1069 } |
| 1070 | 1070 |
| 1071 function errorToString() { | 1071 function errorToString() { |
| 1072 if (IS_NULL_OR_UNDEFINED(this)) { |
| 1073 throw MakeTypeError("obj_ctor_property_non_object", ["toString"]); |
| 1074 } |
| 1072 // This helper function is needed because access to properties on | 1075 // This helper function is needed because access to properties on |
| 1073 // the builtins object do not work inside of a catch clause. | 1076 // the builtins object do not work inside of a catch clause. |
| 1074 function isCyclicErrorMarker(o) { return o === cyclic_error_marker; } | 1077 function isCyclicErrorMarker(o) { return o === cyclic_error_marker; } |
| 1075 | 1078 |
| 1076 try { | 1079 try { |
| 1077 return %_CallFunction(this, errorToStringDetectCycle); | 1080 return %_CallFunction(this, errorToStringDetectCycle); |
| 1078 } catch(e) { | 1081 } catch(e) { |
| 1079 // If this error message was encountered already return the empty | 1082 // If this error message was encountered already return the empty |
| 1080 // string for it instead of recursively formatting it. | 1083 // string for it instead of recursively formatting it. |
| 1081 if (isCyclicErrorMarker(e)) return ''; | 1084 if (isCyclicErrorMarker(e)) return ''; |
| 1082 else throw e; | 1085 else throw e; |
| 1083 } | 1086 } |
| 1084 } | 1087 } |
| 1085 | 1088 |
| 1086 | 1089 |
| 1087 InstallFunctions($Error.prototype, DONT_ENUM, ['toString', errorToString]); | 1090 InstallFunctions($Error.prototype, DONT_ENUM, ['toString', errorToString]); |
| 1088 | 1091 |
| 1089 // Boilerplate for exceptions for stack overflows. Used from | 1092 // Boilerplate for exceptions for stack overflows. Used from |
| 1090 // Isolate::StackOverflow(). | 1093 // Isolate::StackOverflow(). |
| 1091 const kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []); | 1094 const kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []); |
| OLD | NEW |