Hard-abort on assertion and show detailed information, solves #2579
From > [warn} oops to > [assert] /tmp/osrm-backend/src/extractor/extractor.cpp:79 > in: int osrm::extractor::Extractor::run(): false > terminate called without an active exception
This commit is contained in:
parent
6dedd9cb72
commit
df877aca1b
@ -1,20 +0,0 @@
|
||||
#ifndef OSRM_ASSERT_HPP
|
||||
#define OSRM_ASSERT_HPP
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
// Assertion type to be thrown for stack unwinding
|
||||
struct assertionError final : std::logic_error
|
||||
{
|
||||
assertionError(const char *msg) : std::logic_error{msg} {}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -1,16 +1,17 @@
|
||||
#include "util/assert.hpp"
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
#include <sstream>
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
|
||||
namespace
|
||||
{
|
||||
// We throw to guarantee for stack-unwinding and therefore our destructors being called.
|
||||
// We hard-abort on assertion violations.
|
||||
void assertion_failed_msg_helper(
|
||||
char const *expr, char const *msg, char const *function, char const *file, long line)
|
||||
{
|
||||
std::ostringstream fmt;
|
||||
fmt << file << ":" << line << "\nin: " << function << ": " << expr << "\n" << msg;
|
||||
throw osrm::util::assertionError{fmt.str().c_str()};
|
||||
std::cerr << "[assert] " << file << ":" << line << "\nin: " << function << ": " << expr << "\n"
|
||||
<< msg;
|
||||
std::terminate();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user