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
|
#import "PGException.h"
@implementation PGException
+ exceptionWithClass: (Class)class
connection: (PGConnection*)connection
{
return [[[self alloc] initWithClass: class
connection: connection] autorelease];
}
- initWithClass: (Class)class
connection: (PGConnection*)connection
{
self = [super initWithClass: class];
_connection = [connection retain];
return self;
}
- (void)dealloc
{
[_connection release];
[super dealloc];
}
- (OFString*)description
{
return [OFString stringWithFormat:
@"A PostgreSQL operation in class %@ failed: %s", [self inClass],
PQerrorMessage([_connection PG_connection])];
}
- (PGConnection*)connection
{
OF_GETTER(_connection, NO)
}
@end
|
<
|
|
<
<
|
|
>
|
>
>
>
>
>
>
>
>
|
<
|
|
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
+ (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: 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: @"A PostgreSQL operation failed: %@",
_error];
}
- (PGConnection*)connection
{
OF_GETTER(_connection, NO)
}
@end
|