summaryrefslogtreecommitdiff
path: root/src/exception.cpp
blob: 4e7b18b0a3df8d1de41fe4f1b6bcfdcaf6cf4d5c (plain) (blame)
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
#include <exception.h>
#include <exceptions.h>
#include <config.h>
#include <cerrno>
#include <cstring>
#include <utils.h>

using namespace newsbeuter;

exception::exception(unsigned int error_code) : ecode(error_code) { }

exception::~exception() throw() { }

const char * exception::what() const throw() {
	return ::strerror(ecode);
}


const char * matcherexception::what() const throw() {
	static std::string errmsg;
	switch (type) {
		case ATTRIB_UNAVAIL:
			errmsg = utils::strprintf(_("attribute `%s' is not available."), addinfo.c_str());
			break;
		default:
			errmsg = "";
	}
	return errmsg.c_str();
}