OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 | 50 |
51 var kReplacementMarkers = [ "%0", "%1", "%2", "%3" ]; | 51 var kReplacementMarkers = [ "%0", "%1", "%2", "%3" ]; |
52 | 52 |
53 function FormatString(format, message) { | 53 function FormatString(format, message) { |
54 var args = %MessageGetArguments(message); | 54 var args = %MessageGetArguments(message); |
55 var result = ""; | 55 var result = ""; |
56 var arg_num = 0; | 56 var arg_num = 0; |
57 for (var i = 0; i < format.length; i++) { | 57 for (var i = 0; i < format.length; i++) { |
58 var str = format[i]; | 58 var str = format[i]; |
59 for (arg_num = 0; arg_num < kReplacementMarkers.length; arg_num++) { | 59 for (arg_num = 0; arg_num < kReplacementMarkers.length; arg_num++) { |
60 if (str !== kReplacementMarkers[arg_num]) continue; | 60 if (str == kReplacementMarkers[arg_num]) { |
61 try { | 61 try { |
62 str = ToDetailString(args[arg_num]); | 62 str = ToDetailString(args[arg_num]); |
63 } catch (e) { | 63 } catch (e) { |
64 str = "#<error>"; | 64 str = "#<error>"; |
| 65 } |
| 66 break; |
65 } | 67 } |
66 } | 68 } |
67 result += str; | 69 result += str; |
68 } | 70 } |
69 return result; | 71 return result; |
70 } | 72 } |
71 | 73 |
72 | 74 |
73 // To check if something is a native error we need to check the | 75 // To check if something is a native error we need to check the |
74 // concrete native error types. It is not enough to check "obj | 76 // concrete native error types. It is not enough to check "obj |
(...skipping 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1139 throw e; | 1141 throw e; |
1140 } | 1142 } |
1141 } | 1143 } |
1142 | 1144 |
1143 | 1145 |
1144 InstallFunctions($Error.prototype, DONT_ENUM, ['toString', errorToString]); | 1146 InstallFunctions($Error.prototype, DONT_ENUM, ['toString', errorToString]); |
1145 | 1147 |
1146 // Boilerplate for exceptions for stack overflows. Used from | 1148 // Boilerplate for exceptions for stack overflows. Used from |
1147 // Isolate::StackOverflow(). | 1149 // Isolate::StackOverflow(). |
1148 const kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []); | 1150 const kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []); |
OLD | NEW |