blob: 48d90905efad09846c7a13683563b1937d5baf6b [file] [log] [blame]
Mark Slee2ac60ed2007-09-19 21:10:18 +00001#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 Slee77575e62007-09-24 19:24:53 +000033- (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 Reiss0c90f6f2008-02-06 22:18:40 +000040
Mark Slee77575e62007-09-24 19:24:53 +000041 return result;
42}
43
44
Mark Slee2ac60ed2007-09-19 21:10:18 +000045@end