• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Simple Exception Handling, revelation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Simple Exception Handling, revelation


  • Subject: Simple Exception Handling, revelation
  • From: "Frederick C. Lee" <email@hidden>
  • Date: Fri, 19 Apr 2002 14:44:19 -0700

Here's my previous message:

- (double)ComputeResult :(long)sourceValue :(NSString *)sUnit :(NSString
*)tUnit {
NS_DURING {
// Process Data Here.
}
NS_HANDLER {
NSRunAlertPanel(@"Error Panel", @"%@", @"OK", nil, nil,
localException);
}
NS_ENDHANDLER;
return(0);
} // end ComputeResult


What I get is the following:

2002-04-18 16:25:40.278 Converter[798] *** Exception handlers were not
properly removed. Some code has jumped or returned out of an
NS_DURING...NS_HANDLER region without using the NS_VOIDRETURN or
NS_VALUERETURN macros.

Revelation & Solution:

1) Apparently I had manually raised an Exception OUTSIDE of the Block.
This has been fixed:
NS_DURING
[myException raise]; <-- this was above the declaration.

--- My guess is that doing so, I raised myException to the SYSTEM level
which apparently required a way to properly 'remove a handler'; versus
handling within my own Exception Block had it been raised within that
block.

2) I didn't RETAIN the 'myException' object within the init procedure:

- (id)init {
if (self = [super init]) {
[self LoadOnes];
[self LoadFactors];
myException = [NSException
exceptionWithName:@"FileNotFoundException"
reason:@"File Not Found on System"
userInfo:nil];
[myException retain]; <-- THIS WAS MISSING.


}
return self;
}

3) I removed the brackets '{}' and semi-colon ';' which are not needed
in the Exception block.

Ric.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Newbie TextEdit Sample Question
      • From: "Umed Zokirov" <email@hidden>
  • Prev by Date: Re: NSBitmapImageRep problem (I think)
  • Next by Date: NSStepper - How can I tell which arrow has been clicked?
  • Previous by thread: Re: Print margins problem
  • Next by thread: Newbie TextEdit Sample Question
  • Index(es):
    • Date
    • Thread