| 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 928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 939 %FunctionSetInstanceClassName(ErrorPrototype, 'Error'); | 939 %FunctionSetInstanceClassName(ErrorPrototype, 'Error'); |
| 940 %FunctionSetPrototype(f, new ErrorPrototype()); | 940 %FunctionSetPrototype(f, new ErrorPrototype()); |
| 941 } else { | 941 } else { |
| 942 %FunctionSetPrototype(f, new $Error()); | 942 %FunctionSetPrototype(f, new $Error()); |
| 943 } | 943 } |
| 944 %FunctionSetInstanceClassName(f, 'Error'); | 944 %FunctionSetInstanceClassName(f, 'Error'); |
| 945 %SetProperty(f.prototype, 'constructor', f, DONT_ENUM); | 945 %SetProperty(f.prototype, 'constructor', f, DONT_ENUM); |
| 946 f.prototype.name = name; | 946 f.prototype.name = name; |
| 947 %SetCode(f, function(m) { | 947 %SetCode(f, function(m) { |
| 948 if (%_IsConstructCall()) { | 948 if (%_IsConstructCall()) { |
| 949 // Define all the expected properties directly on the error |
| 950 // object. This avoids going through getters and setters defined |
| 951 // on prototype objects. |
| 952 %IgnoreAttributesAndSetProperty(this, 'stack', void 0); |
| 953 %IgnoreAttributesAndSetProperty(this, 'arguments', void 0); |
| 954 %IgnoreAttributesAndSetProperty(this, 'type', void 0); |
| 949 if (m === kAddMessageAccessorsMarker) { | 955 if (m === kAddMessageAccessorsMarker) { |
| 956 // DefineOneShotAccessor always inserts a message property and |
| 957 // ignores setters. |
| 950 DefineOneShotAccessor(this, 'message', function (obj) { | 958 DefineOneShotAccessor(this, 'message', function (obj) { |
| 951 return FormatMessage({type: obj.type, args: obj.arguments}); | 959 return FormatMessage({type: obj.type, args: obj.arguments}); |
| 952 }); | 960 }); |
| 953 } else if (!IS_UNDEFINED(m)) { | 961 } else if (!IS_UNDEFINED(m)) { |
| 954 this.message = ToString(m); | 962 %IgnoreAttributesAndSetProperty(this, 'message', ToString(m)); |
| 955 } | 963 } |
| 956 captureStackTrace(this, f); | 964 captureStackTrace(this, f); |
| 957 } else { | 965 } else { |
| 958 return new f(m); | 966 return new f(m); |
| 959 } | 967 } |
| 960 }); | 968 }); |
| 961 } | 969 } |
| 962 | 970 |
| 963 function captureStackTrace(obj, cons_opt) { | 971 function captureStackTrace(obj, cons_opt) { |
| 964 var stackTraceLimit = $Error.stackTraceLimit; | 972 var stackTraceLimit = $Error.stackTraceLimit; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 985 $Error.captureStackTrace = captureStackTrace; | 993 $Error.captureStackTrace = captureStackTrace; |
| 986 | 994 |
| 987 // Setup extra properties of the Error.prototype object. | 995 // Setup extra properties of the Error.prototype object. |
| 988 $Error.prototype.message = ''; | 996 $Error.prototype.message = ''; |
| 989 | 997 |
| 990 %SetProperty($Error.prototype, 'toString', function toString() { | 998 %SetProperty($Error.prototype, 'toString', function toString() { |
| 991 var type = this.type; | 999 var type = this.type; |
| 992 if (type && !this.hasOwnProperty("message")) { | 1000 if (type && !this.hasOwnProperty("message")) { |
| 993 return this.name + ": " + FormatMessage({ type: type, args: this.arguments }
); | 1001 return this.name + ": " + FormatMessage({ type: type, args: this.arguments }
); |
| 994 } | 1002 } |
| 995 var message = this.message; | 1003 var message = this.hasOwnProperty("message") ? (": " + this.message) : ""; |
| 996 return this.name + (message ? (": " + message) : ""); | 1004 return this.name + message; |
| 997 }, DONT_ENUM); | 1005 }, DONT_ENUM); |
| 998 | 1006 |
| 999 | 1007 |
| 1000 // Boilerplate for exceptions for stack overflows. Used from | 1008 // Boilerplate for exceptions for stack overflows. Used from |
| 1001 // Isolate::StackOverflow(). | 1009 // Isolate::StackOverflow(). |
| 1002 const kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []); | 1010 const kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []); |
| OLD | NEW |