summaryrefslogtreecommitdiff
path: root/src/exception.cpp
blob: 2f2f073932be8da9717ea7a0bc268f2521228b47 (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
#include <exception.h>
#include <exceptions.h>
#include <config.h>
#include <cerrno>
#include <cstring>

using namespace newsbeuter;

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

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

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


const char * matcherexception::what() const throw() {
	static char errmsgbuf[2048];
	switch (type) {
		case ATTRIB_UNAVAIL:
			snprintf(errmsgbuf, sizeof(errmsgbuf), _("attribute `%s' is not available."), addinfo.c_str());
			break;
		default:
			strcpy(errmsgbuf,"");
	}
	return errmsgbuf;
}