ObjPgSQL  Diff

Differences From Artifact [83c7b601db]:

To Artifact [abab265e43]:


16
17
18
19
20
21
22
23






24
25
26
27
28





29
30
31
32
33
34
35
36

37
38
39
40
41
42
43
44
45
46
47
48
49
50

51
52
53
54
55
56
57
58

59
60
16
17
18
19
20
21
22

23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

46
47
48
49
50
51
52
53
54
55
56
57
58
59

60
61
62
63
64
65
66
67

68
69
70







-
+
+
+
+
+
+





+
+
+
+
+







-
+













-
+







-
+


 * PERFORMANCE OF THIS SOFTWARE.
 */

#import "PGException.h"
#import "PGConnection+Private.h"

@implementation PGException
@synthesize connection = _connection;
@synthesize connection = _connection, errorMessage = _errorMessage;

+ (instancetype)exception
{
	OF_UNRECOGNIZED_SELECTOR
}

+ (instancetype)exceptionWithConnection: (PGConnection *)connection
{
	return [[[self alloc] initWithConnection: connection] autorelease];
}

- (instancetype)init
{
	OF_INVALID_INIT_METHOD
}

- (instancetype)initWithConnection: (PGConnection *)connection
{
	self = [super init];

	@try {
		_connection = [connection retain];
		_error = [[OFString alloc]
		_errorMessage = [[OFString alloc]
		    initWithCString: PQerrorMessage([_connection pg_connection])
			   encoding: [OFLocale encoding]];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[_connection release];
	[_error release];
	[_errorMessage release];

	[super dealloc];
}

- (OFString *)description
{
	return [OFString stringWithFormat: @"A PostgreSQL operation failed: %@",
					   _error];
					   _errorMessage];
}
@end