1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
|
-
-
+
-
+
-
-
-
+
-
+
+
-
+
+
+
+
+
+
+
+
+
-
+
-
-
+
|
#import "PGException.h"
@implementation PGException
+ exceptionWithClass: (Class)class
connection: (PGConnection*)connection
+ (instancetype)exceptionWithConnection: (PGConnection*)connection
{
return [[[self alloc] initWithClass: class
return [[[self alloc] initWithConnection: connection] autorelease];
connection: connection] autorelease];
}
- initWithClass: (Class)class
connection: (PGConnection*)connection
- initWithConnection: (PGConnection*)connection
{
self = [super initWithClass: class];
self = [super init];
@try {
_connection = [connection retain];
_connection = [connection retain];
_error = [[OFString alloc]
initWithCString: PQerrorMessage([_connection PG_connection])
encoding: OF_STRING_ENCODING_NATIVE];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)dealloc
{
[_connection release];
[_error release];
[super dealloc];
}
- (OFString*)description
{
return [OFString stringWithFormat:
return [OFString stringWithFormat: @"A PostgreSQL operation failed: %@",
@"A PostgreSQL operation in class %@ failed: %s", [self inClass],
PQerrorMessage([_connection PG_connection])];
_error];
}
- (PGConnection*)connection
{
OF_GETTER(_connection, NO)
}
@end
|