Commit f9d3bc20 authored by Martin Reinecke's avatar Martin Reinecke
Browse files

remove error_handling.cc

parent 9b34409f
......@@ -17,7 +17,6 @@ libmrutil_la_SOURCES = \
mr_util/pointing.h \
mr_util/vec3.h \
mr_util/constants.h \
mr_util/error_handling.cc \
mr_util/error_handling.h \
mr_util/space_filling.cc \
mr_util/space_filling.h \
......
/*
* This file is part of the MR utility library.
*
* This code is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This code 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this code; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* Copyright (C) 2019 Max-Planck-Society
Author: Martin Reinecke */
#include "mr_util/error_handling.h"
using namespace std;
namespace mr {
namespace detail_error_handling {
bool abort_in_progress__ = false;
ostream &CodeLocation::print(ostream &os) const
{
os << file << ": " << line;
if (func) os << " (" << func << ")";
os << ":\n";
return os;
}
void killjob__()
{
// perhaps print stack trace?
exit(1);
}
}}
......@@ -23,7 +23,7 @@
#define MRUTIL_ERROR_HANDLING_H
#include <iostream>
#include <cstdlib>
#include <exception>
namespace mr {
......@@ -37,13 +37,8 @@ namespace detail_error_handling {
#define MR_fail(...) \
do { \
if (!::mr::detail_error_handling::abort_in_progress__) \
{ \
::mr::detail_error_handling::abort_in_progress__ = true; \
::mr::detail_error_handling::streamDump__(::std::cerr, MRUTIL_ERROR_HANDLING_LOC_, "\n", ##__VA_ARGS__, "\n"); \
::mr::detail_error_handling::killjob__(); \
} \
::std::exit(1); \
::mr::detail_error_handling::streamDump__(::std::cerr, MRUTIL_ERROR_HANDLING_LOC_, "\n", ##__VA_ARGS__, "\n"); \
throw ::std::runtime_error("error exit"); \
} while(0)
#define MR_assert(cond,...) \
......@@ -69,8 +64,13 @@ class CodeLocation
inline ::std::ostream &operator<<(::std::ostream &os, const CodeLocation &loc)
{ return loc.print(os); }
extern bool abort_in_progress__;
void killjob__();
inline std::ostream &CodeLocation::print(std::ostream &os) const
{
os << file << ": " << line;
if (func) os << " (" << func << ")";
os << ":\n";
return os;
}
#if (__cplusplus>=201703L) // hyper-elegant C++2017 version
template<typename ...Args>
......
......@@ -32,7 +32,7 @@ else:
def get_extension_modules():
return [Extension('nifty_gridder',
sources=['nifty_gridder.cc', '../mr_util/threading.cc', '../mr_util/error_handling.cc'],
sources=['nifty_gridder.cc', '../mr_util/threading.cc'],
depends=['../mr_util/error_handling.h', '../mr_util/fft.h', '../mr_util/threading.h',
'../mr_util/aligned_array.h', '../mr_util/simd.h', '../mr_util/mav.h',
'../mr_util/cmplx.h', '../mr_util/unity_roots.h',
......
......@@ -36,7 +36,7 @@ else:
def get_extension_modules():
return [Extension('pypocketfft',
language='c++',
sources=['pypocketfft.cc','../mr_util/threading.cc','../mr_util/error_handling.cc'],
sources=['pypocketfft.cc','../mr_util/threading.cc'],
depends=['../mr_util/fft.h', '../mr_util/mav.h', '../mr_util/threading.h',
'../mr_util/aligned_array.h', '../mr_util/simd.h',
'../mr_util/cmplx.h', '../mr_util/unity_roots.h', '../mr_util/error_handling.h',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment