Changeset 42
- Timestamp:
- 10/31/08 19:13:27 (4 years ago)
- Files:
-
- branches/D1.0/src/common/core/exception.d (modified) (7 diffs)
- branches/D1.0/src/compiler/dmd/dmain2.d (modified) (2 diffs)
- trunk/src/common/core/exception.d (modified) (8 diffs)
- trunk/src/compiler/dmd/dmain2.d (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/D1.0/src/common/core/exception.d
r29 r42 19 19 20 20 /** 21 * Thrown on a n array boundserror.22 */ 23 class ArrayBoundsException : Exception24 { 25 this( string file, size_t line ) 26 { 27 super( " Array index out of bounds", file, line );21 * Thrown on a range error. 22 */ 23 class RangeError : Error 24 { 25 this( string file, size_t line ) 26 { 27 super( "Range violation", file, line ); 28 28 } 29 29 } … … 33 33 * Thrown on an assert error. 34 34 */ 35 class AssertE xception : Exception35 class AssertError : Error 36 36 { 37 37 this( string file, size_t line ) … … 50 50 * Thrown on finalize error. 51 51 */ 52 class FinalizeE xception : Exception52 class FinalizeError : Error 53 53 { 54 54 ClassInfo info; … … 70 70 * Thrown on an out of memory error. 71 71 */ 72 class OutOfMemoryE xception : Exception72 class OutOfMemoryError : Error 73 73 { 74 74 this( string file, size_t line ) … … 87 87 * Thrown on a switch error. 88 88 */ 89 class SwitchE xception : Exception89 class SwitchError : Error 90 90 { 91 91 this( string file, size_t line ) … … 135 135 /** 136 136 * A callback for assert errors in D. The user-supplied assert handler will 137 * be called if one has been supplied, otherwise an AssertException will be 137 * be called if one has been supplied, otherwise an AssertError will be thrown. 138 * 139 * Params: 140 * file = The name of the file that signaled this error. 141 * line = The line number on which this error occurred. 142 */ 143 extern (C) void onAssertError( string file, size_t line ) 144 { 145 if( assertHandler is null ) 146 throw new AssertError( file, line ); 147 assertHandler( file, line ); 148 } 149 150 151 /** 152 * A callback for assert errors in D. The user-supplied assert handler will 153 * be called if one has been supplied, otherwise an AssertError will be thrown. 154 * 155 * Params: 156 * file = The name of the file that signaled this error. 157 * line = The line number on which this error occurred. 158 * msg = An error message supplied by the user. 159 */ 160 extern (C) void onAssertErrorMsg( string file, size_t line, string msg ) 161 { 162 if( assertHandler is null ) 163 throw new AssertError( msg, file, line ); 164 assertHandler( file, line, msg ); 165 } 166 167 168 /////////////////////////////////////////////////////////////////////////////// 169 // Internal Error Callbacks 170 /////////////////////////////////////////////////////////////////////////////// 171 172 173 /** 174 * A callback for range errors in D. A RangeError will be thrown. 175 * 176 * Params: 177 * file = The name of the file that signaled this error. 178 * line = The line number on which this error occurred. 179 * 180 * Throws: 181 * RangeError. 182 */ 183 extern (C) void onRangeError( string file, size_t line ) 184 { 185 throw new RangeError( file, line ); 186 } 187 188 189 /** 190 * A callback for finalize errors in D. A FinalizeError will be thrown. 191 * 192 * Params: 193 * e = The exception thrown during finalization. 194 * 195 * Throws: 196 * FinalizeError. 197 */ 198 extern (C) void onFinalizeError( ClassInfo info, Exception ex ) 199 { 200 throw new FinalizeError( info, ex ); 201 } 202 203 204 /** 205 /** 206 * A callback for out of memory errors in D. An OutOfMemoryError will be 138 207 * thrown. 139 208 * 140 * Params: 141 * file = The name of the file that signaled this error. 142 * line = The line number on which this error occurred. 143 */ 144 extern (C) void onAssertError( string file, size_t line ) 145 { 146 if( assertHandler is null ) 147 throw new AssertException( file, line ); 148 assertHandler( file, line ); 149 } 150 151 152 /** 153 * A callback for assert errors in D. The user-supplied assert handler will 154 * be called if one has been supplied, otherwise an AssertException will be 155 * thrown. 156 * 157 * Params: 158 * file = The name of the file that signaled this error. 159 * line = The line number on which this error occurred. 160 * msg = An error message supplied by the user. 161 */ 162 extern (C) void onAssertErrorMsg( string file, size_t line, string msg ) 163 { 164 if( assertHandler is null ) 165 throw new AssertException( msg, file, line ); 166 assertHandler( file, line, msg ); 167 } 168 169 170 /////////////////////////////////////////////////////////////////////////////// 171 // Internal Error Callbacks 172 /////////////////////////////////////////////////////////////////////////////// 173 174 175 /** 176 * A callback for array bounds errors in D. An ArrayBoundsException will be 177 * thrown. 178 * 179 * Params: 180 * file = The name of the file that signaled this error. 181 * line = The line number on which this error occurred. 182 * 183 * Throws: 184 * ArrayBoundsException. 185 */ 186 extern (C) void onArrayBoundsError( string file, size_t line ) 187 { 188 throw new ArrayBoundsException( file, line ); 189 } 190 191 192 /** 193 * A callback for finalize errors in D. A FinalizeException will be thrown. 194 * 195 * Params: 196 * e = The exception thrown during finalization. 197 * 198 * Throws: 199 * FinalizeException. 200 */ 201 extern (C) void onFinalizeError( ClassInfo info, Exception ex ) 202 { 203 throw new FinalizeException( info, ex ); 204 } 205 206 207 /** 208 * A callback for out of memory errors in D. An OutOfMemoryException will be 209 * thrown. 210 * 211 * Throws: 212 * OutOfMemoryException. 209 * Throws: 210 * OutOfMemoryError. 213 211 */ 214 212 extern (C) void onOutOfMemoryError() … … 216 214 // NOTE: Since an out of memory condition exists, no allocation must occur 217 215 // while generating this object. 218 throw cast(OutOfMemoryE xception) cast(void*) OutOfMemoryException.classinfo.init;219 } 220 221 222 /** 223 * A callback for switch errors in D. A SwitchE xceptionwill be thrown.224 * 225 * Params: 226 * file = The name of the file that signaled this error. 227 * line = The line number on which this error occurred. 228 * 229 * Throws: 230 * SwitchE xception.216 throw cast(OutOfMemoryError) cast(void*) OutOfMemoryError.classinfo.init; 217 } 218 219 220 /** 221 * A callback for switch errors in D. A SwitchError will be thrown. 222 * 223 * Params: 224 * file = The name of the file that signaled this error. 225 * line = The line number on which this error occurred. 226 * 227 * Throws: 228 * SwitchError. 231 229 */ 232 230 extern (C) void onSwitchError( string file, size_t line ) 233 231 { 234 throw new SwitchE xception( file, line );232 throw new SwitchError( file, line ); 235 233 } 236 234 branches/D1.0/src/compiler/dmd/dmain2.d
r38 r42 100 100 extern (C) void onAssertError(string file, size_t line); 101 101 extern (C) void onAssertErrorMsg(string file, size_t line, string msg); 102 extern (C) void on ArrayBoundsError(string file, size_t line);102 extern (C) void onRangeError(string file, size_t line); 103 103 extern (C) void onHiddenFuncError(Object o); 104 104 extern (C) void onSwitchError(string file, size_t line); … … 123 123 extern (C) void _d_array_bounds(string file, uint line) 124 124 { 125 on ArrayBoundsError(file, line);125 onRangeError(file, line); 126 126 } 127 127 trunk/src/common/core/exception.d
r29 r42 12 12 private 13 13 { 14 alias void function( string file, size_t line, string msg = null ) assertHandlerType;15 16 assertHandlerType assertHandler = null;17 } 18 19 20 /** 21 * Thrown on a n array boundserror.22 */ 23 class ArrayBoundsException : Exception24 { 25 this( string file, size_t line ) 26 { 27 super( " Array index out of bounds", file, line );14 alias void function( string file, size_t line, string msg = null ) assertHandlerType; 15 16 assertHandlerType assertHandler = null; 17 } 18 19 20 /** 21 * Thrown on a range error. 22 */ 23 class RangeError : Error 24 { 25 this( string file, size_t line ) 26 { 27 super( "Range violation", file, line ); 28 28 } 29 29 } … … 33 33 * Thrown on an assert error. 34 34 */ 35 class AssertE xception : Exception35 class AssertError : Error 36 36 { 37 37 this( string file, size_t line ) … … 50 50 * Thrown on finalize error. 51 51 */ 52 class FinalizeE xception : Exception52 class FinalizeError : Error 53 53 { 54 54 ClassInfo info; … … 70 70 * Thrown on hidden function error. 71 71 */ 72 class HiddenFuncE xception : Exception72 class HiddenFuncError : Error 73 73 { 74 74 this( ClassInfo ci ) … … 82 82 * Thrown on an out of memory error. 83 83 */ 84 class OutOfMemoryE xception : Exception84 class OutOfMemoryError : Error 85 85 { 86 86 this( string file, size_t line ) … … 99 99 * Thrown on a switch error. 100 100 */ 101 class SwitchE xception : Exception101 class SwitchError : Error 102 102 { 103 103 this( string file, size_t line ) … … 147 147 /** 148 148 * A callback for assert errors in D. The user-supplied assert handler will 149 * be called if one has been supplied, otherwise an AssertException will be 149 * be called if one has been supplied, otherwise an AssertError will be thrown. 150 * 151 * Params: 152 * file = The name of the file that signaled this error. 153 * line = The line number on which this error occurred. 154 */ 155 extern (C) void onAssertError( string file, size_t line ) 156 { 157 if( assertHandler is null ) 158 throw new AssertError( file, line ); 159 assertHandler( file, line ); 160 } 161 162 163 /** 164 * A callback for assert errors in D. The user-supplied assert handler will 165 * be called if one has been supplied, otherwise an AssertError will be thrown. 166 * 167 * Params: 168 * file = The name of the file that signaled this error. 169 * line = The line number on which this error occurred. 170 * msg = An error message supplied by the user. 171 */ 172 extern (C) void onAssertErrorMsg( string file, size_t line, string msg ) 173 { 174 if( assertHandler is null ) 175 throw new AssertError( msg, file, line ); 176 assertHandler( file, line, msg ); 177 } 178 179 180 /////////////////////////////////////////////////////////////////////////////// 181 // Internal Error Callbacks 182 /////////////////////////////////////////////////////////////////////////////// 183 184 185 /** 186 * A callback for array bounds errors in D. A RangeError will be thrown. 187 * 188 * Params: 189 * file = The name of the file that signaled this error. 190 * line = The line number on which this error occurred. 191 * 192 * Throws: 193 * RangeError. 194 */ 195 extern (C) void onRangeError( string file, size_t line ) 196 { 197 throw new RangeError( file, line ); 198 } 199 200 201 /** 202 * A callback for finalize errors in D. A FinalizeError will be thrown. 203 * 204 * Params: 205 * e = The exception thrown during finalization. 206 * 207 * Throws: 208 * FinalizeError. 209 */ 210 extern (C) void onFinalizeError( ClassInfo info, Exception ex ) 211 { 212 throw new FinalizeError( info, ex ); 213 } 214 215 216 /** 217 * A callback for hidden function errors in D. A HiddenFuncError will be 150 218 * thrown. 151 219 * 152 * Params: 153 * file = The name of the file that signaled this error. 154 * line = The line number on which this error occurred. 155 */ 156 extern (C) void onAssertError( string file, size_t line ) 157 { 158 if( assertHandler is null ) 159 throw new AssertException( file, line ); 160 assertHandler( file, line ); 161 } 162 163 164 /** 165 * A callback for assert errors in D. The user-supplied assert handler will 166 * be called if one has been supplied, otherwise an AssertException will be 220 * Throws: 221 * HiddenFuncError. 222 */ 223 extern (C) void onHiddenFuncError( Object o ) 224 { 225 throw new HiddenFuncError( o.classinfo ); 226 } 227 228 229 /** 230 * A callback for out of memory errors in D. An OutOfMemoryError will be 167 231 * thrown. 168 232 * 169 * Params: 170 * file = The name of the file that signaled this error. 171 * line = The line number on which this error occurred. 172 * msg = An error message supplied by the user. 173 */ 174 extern (C) void onAssertErrorMsg( string file, size_t line, string msg ) 175 { 176 if( assertHandler is null ) 177 throw new AssertException( msg, file, line ); 178 assertHandler( file, line, msg ); 179 } 180 181 182 /////////////////////////////////////////////////////////////////////////////// 183 // Internal Error Callbacks 184 /////////////////////////////////////////////////////////////////////////////// 185 186 187 /** 188 * A callback for array bounds errors in D. An ArrayBoundsException will be 189 * thrown. 190 * 191 * Params: 192 * file = The name of the file that signaled this error. 193 * line = The line number on which this error occurred. 194 * 195 * Throws: 196 * ArrayBoundsException. 197 */ 198 extern (C) void onArrayBoundsError( string file, size_t line ) 199 { 200 throw new ArrayBoundsException( file, line ); 201 } 202 203 204 /** 205 * A callback for finalize errors in D. A FinalizeException will be thrown. 206 * 207 * Params: 208 * e = The exception thrown during finalization. 209 * 210 * Throws: 211 * FinalizeException. 212 */ 213 extern (C) void onFinalizeError( ClassInfo info, Exception ex ) 214 { 215 throw new FinalizeException( info, ex ); 216 } 217 218 219 /** 220 * A callback for hidden function errors in D. A HiddenFuncException will be 221 * thrown. 222 * 223 * Throws: 224 * HiddenFuncException. 225 */ 226 extern (C) void onHiddenFuncError( Object o ) 227 { 228 throw new HiddenFuncException( o.classinfo ); 229 } 230 231 232 /** 233 * A callback for out of memory errors in D. An OutOfMemoryException will be 234 * thrown. 235 * 236 * Throws: 237 * OutOfMemoryException. 233 * Throws: 234 * OutOfMemoryError. 238 235 */ 239 236 extern (C) void onOutOfMemoryError() … … 241 238 // NOTE: Since an out of memory condition exists, no allocation must occur 242 239 // while generating this object. 243 throw cast(OutOfMemoryE xception) cast(void*) OutOfMemoryException.classinfo.init;244 } 245 246 247 /** 248 * A callback for switch errors in D. A SwitchE xceptionwill be thrown.249 * 250 * Params: 251 * file = The name of the file that signaled this error. 252 * line = The line number on which this error occurred. 253 * 254 * Throws: 255 * SwitchE xception.240 throw cast(OutOfMemoryError) cast(void*) OutOfMemoryError.classinfo.init; 241 } 242 243 244 /** 245 * A callback for switch errors in D. A SwitchError will be thrown. 246 * 247 * Params: 248 * file = The name of the file that signaled this error. 249 * line = The line number on which this error occurred. 250 * 251 * Throws: 252 * SwitchError. 256 253 */ 257 254 extern (C) void onSwitchError( string file, size_t line ) 258 255 { 259 throw new SwitchE xception( file, line );256 throw new SwitchError( file, line ); 260 257 } 261 258 trunk/src/compiler/dmd/dmain2.d
r38 r42 102 102 extern (C) void onAssertError(string file, size_t line); 103 103 extern (C) void onAssertErrorMsg(string file, size_t line, string msg); 104 extern (C) void on ArrayBoundsError(string file, size_t line);104 extern (C) void onRangeError(string file, size_t line); 105 105 extern (C) void onHiddenFuncError(Object o); 106 106 extern (C) void onSwitchError(string file, size_t line); … … 125 125 extern (C) void _d_array_bounds(string file, uint line) 126 126 { 127 on ArrayBoundsError(file, line);127 onRangeError(file, line); 128 128 } 129 129
