morte error handling fixups

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/sqlclient/trunk@39067 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2015-10-14 13:28:52 +00:00
parent 14c31894a0
commit 3c0f8a4840

View file

@ -664,8 +664,12 @@ connectQuote(NSString *str)
if (result != 0) if (result != 0)
{ {
PQclear(result); PQclear(result);
result = 0;
}
if (PQstatus(connection) != CONNECTION_OK)
{
[self backendDisconnect];
} }
[self backendDisconnect];
[NSException raise: SQLException format: @"Error executing %@: %@", [NSException raise: SQLException format: @"Error executing %@: %@",
stmt, str]; stmt, str];
} }
@ -677,13 +681,11 @@ connectQuote(NSString *str)
} }
NS_HANDLER NS_HANDLER
{ {
NSString *n = [localException name];
if (result != 0) if (result != 0)
{ {
PQclear(result); PQclear(result);
} }
if (YES == connected && [n isEqual: SQLConnectionException] == YES) if (YES == connected && PQstatus(connection) != CONNECTION_OK)
{ {
[self disconnect]; [self disconnect];
} }
@ -1020,8 +1022,12 @@ static inline unsigned int trim(char *str, unsigned len)
if (result != 0) if (result != 0)
{ {
PQclear(result); PQclear(result);
result = 0;
}
if (PQstatus(connection) != CONNECTION_OK)
{
[self backendDisconnect];
} }
[self backendDisconnect];
[NSException raise: SQLException format: @"Error executing %@: %@", [NSException raise: SQLException format: @"Error executing %@: %@",
stmt, str]; stmt, str];
} }
@ -1142,13 +1148,12 @@ static inline unsigned int trim(char *str, unsigned len)
} }
NS_HANDLER NS_HANDLER
{ {
NSString *n = [localException name];
if (result != 0) if (result != 0)
{ {
PQclear(result); PQclear(result);
result = 0;
} }
if (YES == connected && [n isEqual: SQLConnectionException] == YES) if (YES == connected && PQstatus(connection) != CONNECTION_OK)
{ {
[self disconnect]; [self disconnect];
} }