ObjPgSQL  Artifact [4cb1491070]

Artifact 4cb1491070a3e879be58d92140348706ed9ff7011fa434081e49a6098d0881b5:

  • File exceptions/PGException.m — part of check-in [bec524d06b] at 2014-07-18 21:40:09 on branch trunk — Adjust to ObjFW changes (user: js size: 793)
  • File src/exceptions/PGException.m — part of check-in [8679c61b2c] at 2014-07-18 23:35:18 on branch trunk — Add a proper build system (user: js size: 793)

#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