/usr/include/rostlab/rostlab_stdexcept.h is in librostlab3-dev 1.0.20-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | /*
Copyright (C) 2011 Laszlo Kajan, Technical University of Munich, Germany
This file is part of librostlab.
librostlab is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ROSTLAB_STDEXCEPT
#define ROSTLAB_STDEXCEPT
#include <execinfo.h>
#include <stdexcept>
#include <stdio.h>
#include <stdlib.h>
#include <string>
namespace rostlab {
class error_backtracer
{
private:
std::string _backtrace;
public:
error_backtracer()
{
const int bufsize = 64;
void* buffer[bufsize];
char **strings;
_backtrace.reserve(4096);
size_t nptrs = ::backtrace(buffer, bufsize);
strings = backtrace_symbols(buffer, nptrs);
if (strings == NULL) { perror("backtrace_symbols"); exit(EXIT_FAILURE); }
for( size_t j = 0; j < nptrs; ++j )
{
_backtrace += std::string( strings[j] ) + "\n";
if( _backtrace.capacity() == _backtrace.size() ) _backtrace.reserve( _backtrace.size() * 2 );
}
free(strings);
}
virtual ~error_backtracer() throw() {}
virtual const std::string&
backtrace() const { return _backtrace; }
};
class exception : public error_backtracer, public std::exception
{
public:
exception() : error_backtracer(), std::exception(){}
};
class runtime_error : public error_backtracer, public std::runtime_error
{
public:
runtime_error( const std::string& __msg ) : error_backtracer(), std::runtime_error( __msg + "\nBacktrace:\n" + backtrace() ){}
};
} // namespace rostlab
#endif // ROSTLAB_STDEXCEPT
// vim:et:ts=4:ai:syntax=cpp:
|