/* exception - test for MaskedException from libMathArray Copyright (C) 1995, Adam Fedor */ #ifdef NEXT_FOUNDATION #include #include #else #include #include #endif #include #include "MathArray/MaskedException.h" @interface SpecialHandler : NSObject @end @implementation SpecialHandler - (void)exceptionWithName: (NSString *)raise_name reason: (NSString *)raise_reason userInfo: (NSDictionary *)raise_info { printf("The exception [%s] was handled by %s\n", [raise_name cString], [[self description] cString]); } @end int main() { id handler; NSAutoreleasePool* pool = [NSAutoreleasePool new]; [MaskedException bodysnatchNSException]; [MaskedException setMask:LogException forException:NSGenericException]; [NSException raise:NSGenericException format:@"This exception should be logged and ignored"]; handler = [SpecialHandler new]; [MaskedException setHandler:handler forExceptionsWithPrefix:@"NS"]; [NSException raise:NSInvalidArgumentException format:@"This exception should be handled"]; [pool release]; return 0; }