Revision: 27884
http://sourceforge.net/p/bibdesk/svn/27884
Author: hofman
Date: 2022-09-10 23:23:18 +0000 (Sat, 10 Sep 2022)
Log Message:
-----------
catch NSException separately using multiple catch blocks
Modified Paths:
--------------
trunk/bibdesk/BDSKSharingClient.m
trunk/bibdesk/BDSKSharingServer.m
Modified: trunk/bibdesk/BDSKSharingClient.m
===================================================================
--- trunk/bibdesk/BDSKSharingClient.m 2022-09-10 21:17:17 UTC (rev 27883)
+++ trunk/bibdesk/BDSKSharingClient.m 2022-09-10 23:23:18 UTC (rev 27884)
@@ -395,8 +395,8 @@
[conn setDelegate:self];
proxy = [conn rootProxy];
}
- @catch (id exception) {
-
+ @catch (NSException *exception) {
+
[conn setDelegate:nil];
[conn setRootObject:nil];
[conn invalidate];
@@ -403,30 +403,32 @@
conn = nil;
proxy = nil;
- // flag authentication failures so we get a prompt the next time
around (in case our password was wrong)
- // we also get this if the user canceled, since an empty data will
be returned
- if([exception respondsToSelector:@selector(name)] && [[exception
name] isEqual:NSFailedAuthenticationException]){
-
- // if the user didn't cancel, set an auth failure flag and
show an alert
- if(atomic_load(&canceledAuthentication) == NO){
- atomic_store(&authenticationFailed, YES);
- // don't show the alert when we couldn't authenticate when
cleaning up
- if([self shouldKeepRunning])
- [self runAuthenticationFailedAlert];
- }
-
- } else if([exception respondsToSelector:@selector(name)] &&
[[exception name] isEqual:NSGenericException]){
-
- // this is thrown when authentication is canceled
- if(atomic_load(&canceledAuthentication) == NO){
- @throw [NSString stringWithFormat:@"%@: exception \"%@\"
while connecting to remote server %@", NSStringFromSelector(_cmd), exception,
[service hostName]];
- }
-
- } else {
+ if (atomic_load(&canceledAuthentication) && ([[exception name]
isEqual:NSGenericException] || [[exception name]
isEqual:NSFailedAuthenticationException])) {
+ // NSGenericException is thrown when authentication is canceled
+ // don't throw when canceled
+ } else if([[exception name]
isEqual:NSFailedAuthenticationException]){
+ // flag authentication failures so we get a prompt the next
time around (in case our password was wrong)
+ atomic_store(&authenticationFailed, YES);
+ // don't show the alert when we couldn't authenticate when
cleaning up
+ if([self shouldKeepRunning])
+ [self runAuthenticationFailedAlert];
+ // unfortunately for newer OS version this exception is not
thrown
+ // should we also interpret NSPortTimeoutException as
authentication failure?
+ } else{
@throw [NSString stringWithFormat:@"%@: exception \"%@\" while
connecting to remote server %@", NSStringFromSelector(_cmd), exception,
[service hostName]];
}
}
+ @catch (id exception) {
+ [conn setDelegate:nil];
+ [conn setRootObject:nil];
+ [conn invalidate];
+ conn = nil;
+ proxy = nil;
+
+ @throw [NSString stringWithFormat:@"%@: exception \"%@\" while
connecting to remote server %@", NSStringFromSelector(_cmd), exception,
[service hostName]];
+ }
+
if (proxy != nil) {
[proxy setProtocolForProxy:@protocol(BDSKSharingServer)];
Modified: trunk/bibdesk/BDSKSharingServer.m
===================================================================
--- trunk/bibdesk/BDSKSharingServer.m 2022-09-10 21:17:17 UTC (rev 27883)
+++ trunk/bibdesk/BDSKSharingServer.m 2022-09-10 23:23:18 UTC (rev 27884)
@@ -887,7 +887,7 @@
[self setAuthenticated:YES];
legacyAuthentication = YES;
}
- return YES;
+ return NO;
}
- (BOOL)connection:(NSConnection *)aConnection
handleRequest:(NSDistantObjectRequest *)doRequest {
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit