2 // WOTestLowLevelException.m
5 // Created by Wincent Colaiuta on 22 October 2006.
7 // Copyright 2006-2007 Wincent Colaiuta.
8 // This program is free software: you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation, either version 3 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #import "WOTestLowLevelException.h"
24 @implementation WOTestLowLevelException
26 + (WOTestLowLevelException *)exceptionWithType:(ExceptionKind)kind
28 NSString *reason = [NSString stringWithFormat:
29 @"a low-level exception (\"%@\") was caught during execution: the most likely cause is a programming error in the software "
30 @"being tested; be aware that the reliability of the most recent test and all subsequent tests may be adversely affected",
31 [self nameForType:kind]];
33 NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:
34 [NSNumber numberWithInt:kind], WOTestLowLevelExceptionKind, nil];
36 return [[self alloc] initWithName:WOTestLowLevelExceptionName reason:reason userInfo:userInfo];
39 + (NSString *)nameForType:(ExceptionKind)kind
44 case kUnknownException: name = @"unknown exception"; break;
45 case kIllegalInstructionException: name = @"illegal instruction exception"; break;
46 case kTrapException: name = @"trap exception"; break;
47 case kAccessException: name = @"access exception exception"; break;
48 case kUnmappedMemoryException: name = @"unmapped memory exception"; break;
49 case kExcludedMemoryException: name = @"excluded memory exception"; break;
50 case kReadOnlyMemoryException: name = @"read only memory exception"; break;
51 case kUnresolvablePageFaultException: name = @"unresolvable page fault exception"; break;
52 case kPrivilegeViolationException: name = @"privilege violation exception"; break;
53 case kTraceException: name = @"trace exception"; break;
54 case kInstructionBreakpointException: name = @"instruction breakpoint exception"; break;
55 case kDataBreakpointException: name = @"data breakpoint exception"; break;
56 case kIntegerException: name = @"integer exception"; break;
57 case kFloatingPointException: name = @"floating point exception"; break;
58 case kStackOverflowException: name = @"stack overflow exception"; break;
59 case kTaskTerminationException: name = @"task termination exception"; break;
60 case kTaskCreationException: name = @"task creation exception"; break;
61 case kDataAlignmentException: name = @"data alignment exception"; break;
62 default: name = @"UNKNOWN";
69 __attribute__((used)) __attribute__((visibility("default"))) NSString *WOTestLowLevelExceptionName = @"WOTestLowLevelException";
70 __attribute__((used)) __attribute__((visibility("default"))) NSString *WOTestLowLevelExceptionKind = @"WOTestLowLevelExceptionKind";