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

@ -1,21 +1,17 @@
#import "PGCommandFailedException.h"
@implementation PGCommandFailedException
+ exceptionWithClass: (Class)class
connection: (PGConnection*)connection
command: (OFString*)command
+ (instancetype)exceptionWithConnection: (PGConnection*)connection
command: (OFString*)command
{
return [[[self alloc] initWithClass: class
connection: connection
command: command] autorelease];
return [[[self alloc] initWithConnection: connection
command: command] autorelease];
}
- initWithClass: (Class)class
connection: (PGConnection*)connection
command: (OFString*)command
- initWithConnection: (PGConnection*)connection
command: (OFString*)command
{
self = [super initWithClass: class
connection: connection];
self = [super initWithConnection: connection];
@try {
_command = [command copy];
@ -36,10 +32,8 @@
- (OFString*)description
{
return [OFString stringWithFormat:
@"A PostgreSQL command in class %@ failed: %s\nCommand: %@",
[self inClass], PQerrorMessage([_connection PG_connection]),
_command];
return [OFString stringWithFormat: @"A PostgreSQL command failed: %@\n"
@"Command: %@", _error, _command];
}
- (OFString*)command