bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Recursive Exeption raising again


From: Markus Hitter
Subject: Recursive Exeption raising again
Date: Wed, 20 Mar 2002 19:41:04 +0100

Hello,

on a second thinking, I found a solution which fits my own wishlist better:


+ (void) raise: (NSString*)name
        format: (NSString*)format
     arguments: (va_list)argList
{
  static BOOL recursionCheck = NO;
  NSString      *reason;
  NSException   *except;

//fprintf(stderr, "NSException: %s\n", [name cString]); fflush(stderr);

  if (recursionCheck)
    {
      fprintf(stderr, "Recursive Exception detected.\n");
      fprintf(stderr, "Name: %s\nReason: ", [name cString]);
      vfprintf(stderr, [format cString], argList);
      fprintf(stderr, "\n");
      fflush(stderr);
//      abort();
    } else {
      /* This potentially raises an exception again. recursionCheck
         protects against endless recursion. */
      recursionCheck = YES;
      reason = [NSString stringWithFormat: format arguments: argList];
      recursionCheck = NO;
except = [self exceptionWithName: name reason: reason userInfo: nil];
      [except raise];
    }
}


Simply removing the abort() ended the recursion after three loops but allowed more exceptions. Surprise! Who resets recusionCheck? Are there more than one
instances of the NSException class?

With the first fprintf() uncommented, I get:

NSException: NSGenericException
NSException: NSGenericException
Recursive Exception detected.
Name: NSGenericException
Reason: subclass NSConstantString(instance) should override length
NSException: NSGenericException
Recursive Exception detected.
Name: NSGenericException
Reason: subclass NSConstantString(instance) should override length
NSException: NSGenericException
Recursive Exception detected.
Name: NSGenericException
Reason: subclass NSConstantString(instance) should override length
NSException: NSGenericException
NSException: NSGenericException
Recursive Exception detected.
Name: NSGenericException
Reason: subclass NSConstantString(instance) should override length
NSException: NSGenericException
Recursive Exception detected.
Name: NSGenericException
Reason: subclass NSConstantString(instance) should override length
NSException: NSGenericException
Recursive Exception detected.
Name: NSGenericException
Reason: subclass NSConstantString(instance) should override length
Uncaught exception , reason:


You notice the second double of "NSException: NSGenericException" around the middle?

But then, this might be a result of something completely else.



Have fun,
Markus

- - - - - - - - - - - - - - - - - - -
Dipl. Ing. Markus Hitter
http://www.jump-ing.de/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]