Add a proper build system
FossilOrigin-Name: 8679c61b2c82da9daa316ed5eb90ba1b69e608127afa318cbdbff56b53d65a74
This commit is contained in:
parent
71342537cf
commit
35212e3305
28 changed files with 5118 additions and 76 deletions
44
src/exceptions/PGException.m
Normal file
44
src/exceptions/PGException.m
Normal file
|
@ -0,0 +1,44 @@
|
|||
#import "PGException.h"
|
||||
|
||||
@implementation PGException
|
||||
+ (instancetype)exceptionWithConnection: (PGConnection*)connection
|
||||
{
|
||||
return [[[self alloc] initWithConnection: connection] autorelease];
|
||||
}
|
||||
|
||||
- initWithConnection: (PGConnection*)connection
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
@try {
|
||||
_connection = [connection retain];
|
||||
_error = [[OFString alloc]
|
||||
initWithCString: PQerrorMessage([_connection PG_connection])
|
||||
encoding: [OFString nativeOSEncoding]];
|
||||
} @catch (id e) {
|
||||
[self release];
|
||||
@throw e;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[_connection release];
|
||||
[_error release];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (OFString*)description
|
||||
{
|
||||
return [OFString stringWithFormat: @"A PostgreSQL operation failed: %@",
|
||||
_error];
|
||||
}
|
||||
|
||||
- (PGConnection*)connection
|
||||
{
|
||||
OF_GETTER(_connection, NO)
|
||||
}
|
||||
@end
|
Loading…
Add table
Add a link
Reference in a new issue