blob: 0160e3b8a871ec1e25f84a5aceda3b5bf1c7c431 [file] [log] [blame]
David Reissea2cba82009-03-30 21:35:00 +00001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
Mark Slee2ac60ed2007-09-19 21:10:18 +000020#import "TException.h"
Jake Farrell9689d892011-12-06 01:07:17 +000021#import "TObjective-C.h"
Mark Slee2ac60ed2007-09-19 21:10:18 +000022
23@implementation TException
24
25+ (id) exceptionWithName: (NSString *) name
26{
27 return [self exceptionWithName: name reason: @"unknown" error: nil];
28}
29
30
31+ (id) exceptionWithName: (NSString *) name
32 reason: (NSString *) reason
33{
34 return [self exceptionWithName: name reason: reason error: nil];
35}
36
37
38+ (id) exceptionWithName: (NSString *) name
39 reason: (NSString *) reason
40 error: (NSError *) error
41{
42 NSDictionary * userInfo = nil;
43 if (error != nil) {
44 userInfo = [NSDictionary dictionaryWithObject: error forKey: @"error"];
45 }
46
47 return [super exceptionWithName: name
48 reason: reason
49 userInfo: userInfo];
50}
51
52
Mark Slee77575e62007-09-24 19:24:53 +000053- (NSString *) description
54{
55 NSMutableString * result = [NSMutableString stringWithString: [self name]];
56 [result appendFormat: @": %@", [self reason]];
57 if ([self userInfo] != nil) {
58 [result appendFormat: @"\n userInfo = %@", [self userInfo]];
59 }
David Reiss0c90f6f2008-02-06 22:18:40 +000060
Mark Slee77575e62007-09-24 19:24:53 +000061 return result;
62}
63
64
Mark Slee2ac60ed2007-09-19 21:10:18 +000065@end