Skip to content

Commit

Permalink
NSException: Avoid re-throwing exception from within NS_HANDLER
Browse files Browse the repository at this point in the history
  • Loading branch information
qmfrederik committed Feb 11, 2024
1 parent 78a0098 commit a32c9dc
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions Source/NSOperation.m
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ - (void) start
ENTER_POOL

double prio = [NSThread threadPriority];
NSException* caughtException = nil;

AUTORELEASE(RETAIN(self)); // Make sure we exist while running.
[internal->lock lock];
Expand Down Expand Up @@ -453,12 +454,16 @@ - (void) start
}
NS_HANDLER
{
[internal->lock unlock];
[localException raise];
caughtException = localException;
}
NS_ENDHANDLER
[internal->lock unlock];

if (caughtException != nil)
{
[caughtException raise];
}

NS_DURING
{
if (NO == [self isCancelled])
Expand All @@ -470,10 +475,15 @@ - (void) start
NS_HANDLER
{
[NSThread setThreadPriority: prio];
[localException raise];
caughtException = localException;
}
NS_ENDHANDLER;

if (caughtException != nil)
{
[caughtException raise];
}

[self _finish];
LEAVE_POOL
}
Expand Down

0 comments on commit a32c9dc

Please sign in to comment.