Mark Slee | 2ac60ed | 2007-09-19 21:10:18 +0000 | [diff] [blame] | 1 | #import "TException.h" |
| 2 | |
| 3 | @implementation TException |
| 4 | |
| 5 | + (id) exceptionWithName: (NSString *) name |
| 6 | { |
| 7 | return [self exceptionWithName: name reason: @"unknown" error: nil]; |
| 8 | } |
| 9 | |
| 10 | |
| 11 | + (id) exceptionWithName: (NSString *) name |
| 12 | reason: (NSString *) reason |
| 13 | { |
| 14 | return [self exceptionWithName: name reason: reason error: nil]; |
| 15 | } |
| 16 | |
| 17 | |
| 18 | + (id) exceptionWithName: (NSString *) name |
| 19 | reason: (NSString *) reason |
| 20 | error: (NSError *) error |
| 21 | { |
| 22 | NSDictionary * userInfo = nil; |
| 23 | if (error != nil) { |
| 24 | userInfo = [NSDictionary dictionaryWithObject: error forKey: @"error"]; |
| 25 | } |
| 26 | |
| 27 | return [super exceptionWithName: name |
| 28 | reason: reason |
| 29 | userInfo: userInfo]; |
| 30 | } |
| 31 | |
| 32 | |
Mark Slee | 77575e6 | 2007-09-24 19:24:53 +0000 | [diff] [blame] | 33 | - (NSString *) description |
| 34 | { |
| 35 | NSMutableString * result = [NSMutableString stringWithString: [self name]]; |
| 36 | [result appendFormat: @": %@", [self reason]]; |
| 37 | if ([self userInfo] != nil) { |
| 38 | [result appendFormat: @"\n userInfo = %@", [self userInfo]]; |
| 39 | } |
David Reiss | 0c90f6f | 2008-02-06 22:18:40 +0000 | [diff] [blame] | 40 | |
Mark Slee | 77575e6 | 2007-09-24 19:24:53 +0000 | [diff] [blame] | 41 | return result; |
| 42 | } |
| 43 | |
| 44 | |
Mark Slee | 2ac60ed | 2007-09-19 21:10:18 +0000 | [diff] [blame] | 45 | @end |