ftp.nice.ch/pub/next/science/mathematics/MathArray.0.33.s.tar.gz#/MathArray-0.33/checks/exception.m

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>
#include <foundation/NSAutoreleasePool.h>
#else
#include <Foundation/NSString.h>
#include <Foundation/NSAutoreleasePool.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;
  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;
}

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.