summaryrefslogtreecommitdiff
path: root/libpqpp/pq-error.cpp
blob: 0d0299c281e92eb159f904da5582d5e6f28d728f (plain)
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
#include "pq-error.h"
#include <string.h>

PQ::Error::Error() :
	msg(NULL)
{
}

PQ::Error::Error(const PQ::Error & e) :
	msg(e.msg ? strdup(e.msg) : NULL)
{
}

PQ::Error::Error(const char * e) :
	msg(e ? strdup(e) : NULL)
{
}

PQ::Error::~Error() throw()
{
	free(msg);
}

const char *
PQ::Error::what() const throw()
{
	return msg ? msg : "No message";
}

PQ::ConnectionError::ConnectionError(const PGconn * conn) :
	PQ::Error(PQerrorMessage(conn))
{
}