Improve exceptions.

FossilOrigin-Name: 12b5ef483a1f9eae92df83cf8a6aded299ef10dd2972059a36c79d299e676a0d
This commit is contained in:
Jonathan Schleifer 2013-07-23 14:11:41 +00:00
parent 16dc91b0e7
commit 25c48048a1
8 changed files with 50 additions and 61 deletions

View file

@ -41,13 +41,11 @@
}
if ((_connnection = PQconnectdb([connectionInfo UTF8String])) == NULL)
@throw [OFOutOfMemoryException
exceptionWithClass: [self class]];
@throw [OFOutOfMemoryException exception];
if (PQstatus(_connnection) == CONNECTION_BAD)
@throw [PGConnectionFailedException
exceptionWithClass: [self class]
connection: self];
exceptionWithConnection: self];
[pool release];
}
@ -72,9 +70,8 @@
if (PQresultStatus(result) == PGRES_FATAL_ERROR) {
PQclear(result);
@throw [PGCommandFailedException
exceptionWithClass: [self class]
connection: self
command: command];
exceptionWithConnection: self
command: command];
}
switch (PQresultStatus(result)) {
@ -86,9 +83,8 @@
default:
PQclear(result);
@throw [PGCommandFailedException
exceptionWithClass: [self class]
connection: self
command: command];
exceptionWithConnection: self
command: command];
}
}
@ -115,15 +111,17 @@
if ([parameter isKindOfClass: [OFString class]])
values[i++] = [parameter UTF8String];
else if ([parameter isKindOfClass: [OFNumber class]]) {
switch ([parameter type]) {
OFNumber *number = parameter;
switch ([number type]) {
case OF_NUMBER_BOOL:
if ([parameter boolValue])
if ([number boolValue])
values[i++] = "t";
else
values[i++] = "f";
break;
default:
values[i++] = [[parameter description]
values[i++] = [[number description]
UTF8String];
break;
}
@ -151,9 +149,8 @@
default:
PQclear(result);
@throw [PGCommandFailedException
exceptionWithClass: [self class]
connection: self
command: command];
exceptionWithConnection: self
command: command];
}
}
@ -214,9 +211,8 @@
if (PQresultStatus(result) != PGRES_COMMAND_OK) {
PQclear(result);
@throw [PGCommandFailedException
exceptionWithClass: [self class]
connection: self
command: command];
exceptionWithConnection: self
command: command];
}
PQclear(result);