This is exception.m in view mode; [Download] [Up]
/* exception - test for MaskedException from libMathArray Copyright (C) 1995, Adam Fedor */ #ifdef NEXT_FOUNDATION #include <foundation/NSString.h> #else #include <Foundation/NSString.h> #endif #include <stdio.h> #include "MathArray/MaskedException.h" @interface SpecialHandler : NSObject <MaskedExceptionHandling> @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 <MaskedExceptionHandling> handler; [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"]; return 0; }
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.