summaryrefslogtreecommitdiff
path: root/service/uptr.cpp
blob: de38d0b097fa6f637c0dc8871e70e31ea1478ba1 (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
#include "uptr.h"
#include <boost/assert.hpp>
#include <exception>
#include <execinfo.h>
#include <stdlib.h>
#include <string>

namespace MirrorSearch {

	std::string
	failingFunction(void * const func)
	{
		char ** fn = backtrace_symbols(&func, 1);
		BOOST_ASSERT(fn);
		BOOST_ASSERT(*fn);
		std::string funcName(*fn);
		free(fn);
		return funcName;
	}

	void
	defaultErrorHandler(const std::string & fn)
	{
		throw std::runtime_error("Fatal error in " + fn);
	}
}