brintos

brintos / llvm-project-archived public Read only

0
0
Text · 817 B · db98f5c Raw
38 lines · plain
1#import <Foundation/Foundation.h>2 3@interface MyException : NSException4{5  int extra_info;6}7- (NSException *) initWithExtraInfo: (int) info;8@end9 10@implementation MyException11- (NSException *) initWithExtraInfo: (int) info12{13  [super initWithName: @"NSException" reason: @"Simple Reason" userInfo: nil];14  self->extra_info = info;15  return self;16}17@end18 19int20main(int argc, char **argv)21{22  // Set a breakpoint here for plain exception:23  @try {24    NSException *plain_exc = [[NSException alloc] initWithName: @"NSException" reason: @"Simple Reason" userInfo: nil];25    [plain_exc raise];26  }27  @catch (id anException) {}28 29  // Set a breakpoint here for MyException:30  @try {31    MyException *my_exc = [[MyException alloc] initWithExtraInfo: 100];32    [my_exc raise];33  }34  @catch (id anException) {}35 36  return 0;37}38