comparison base/src/java/lang/exceptions.d @ 112:9f4c18c268b2

Update to compile and execute with dmd 2.052.
author kntroh
date Wed, 16 Mar 2011 21:53:53 +0900
parents 48d4ee626868
children 536e43f63c81
comparison
equal deleted inserted replaced
111:b6e9904989ed 112:9f4c18c268b2
130 } 130 }
131 } 131 }
132 132
133 class RuntimeException : Exception { 133 class RuntimeException : Exception {
134 this( String file, long line, String msg = null){ 134 this( String file, long line, String msg = null){
135 super( msg, file, line ); 135 super( msg, file, cast(size_t) line );
136 } 136 }
137 this( String e = null){ 137 this( String e = null){
138 super(e); 138 super(e);
139 } 139 }
140 this( Exception e ){ 140 this( Exception e ){
168 ExceptionPrintStackTrace( e, & getDwtLogger().error ); 168 ExceptionPrintStackTrace( e, & getDwtLogger().error );
169 } 169 }
170 170
171 /// Extension to the D Exception 171 /// Extension to the D Exception
172 void ExceptionPrintStackTrace( Throwable e, void delegate ( String file, ulong line, String fmt, ... ) dg ){ 172 void ExceptionPrintStackTrace( Throwable e, void delegate ( String file, ulong line, String fmt, ... ) dg ){
173 Throwable exception = e; 173 version(Tango){
174 while( exception !is null ){ 174 Throwable exception = e;
175 dg( exception.file, exception.line, "Exception in {}({}): {}", exception.file, exception.line, exception.msg ); 175 while( exception !is null ){
176 if( exception.info !is null ){ 176 dg( exception.file, exception.line, "Exception in {}({}): {}", exception.file, exception.line, exception.msg );
177 foreach( frame; exception.info ){ 177 if( exception.info !is null ){
178 dg( exception.file, exception.line, "trc {} {}", frame.file, frame.line ); 178 foreach( frame; exception.info ){
179 } 179 dg( exception.file, exception.line, "trc {} {}", frame.file, frame.line );
180 } 180 }
181 exception = exception.next; 181 }
182 exception = exception.next;
183 }
184 } else { // Phobos
185 Throwable exception = e;
186 while( exception !is null ){
187 dg( exception.file, exception.line, "Exception in {}({}): {}", exception.file, exception.line, exception.msg );
188 if( exception.info !is null ){
189 foreach( line, file; exception.info ){
190 dg( exception.file, exception.line, "trc {} {}", file, line );
191 }
192 }
193 exception = exception.next;
194 }
182 } 195 }
183 } 196 }
184 197
185 void PrintStackTrace( int deepth = 100, String prefix = "trc" ){ 198 void PrintStackTrace( int deepth = 100, String prefix = "trc" ){
186 auto e = new Exception( null ); 199 version(Tango){
187 int idx = 0; 200 auto e = new Exception( null );
188 const start = 3; 201 int idx = 0;
189 foreach( frame; e.info ){ 202 const start = 3;
190 if( idx >= start && idx < start+deepth ) { 203 foreach( frame; e.info ){
191 getDwtLogger().trace( __FILE__, __LINE__, "{} {}: {}", prefix, frame.file, frame.line ); 204 if( idx >= start && idx < start+deepth ) {
192 } 205 getDwtLogger().trace( __FILE__, __LINE__, "{} {}: {}", prefix, frame.file, frame.line );
193 idx++; 206 }
194 } 207 idx++;
195 } 208 }
209 } else { // Phobos
210 auto e = new Exception( null );
211 int idx = 0;
212 const start = 3;
213 foreach( line, file; e.info ){
214 if( idx >= start && idx < start+deepth ) {
215 getDwtLogger().trace( __FILE__, __LINE__, "{} {}: {}", prefix, file, line );
216 }
217 idx++;
218 }
219 }
220 }