Commit f0acd5a6 authored by Jean-Eric Campagne's avatar Jean-Eric Campagne
Browse files

(JEC) 9/4/15 use LagSHTError instead of planck ones

parent acda9653
......@@ -27,7 +27,6 @@ clean :
CXXOBJ = $(OBJ)laguerreBuilder.o \
$(OBJ)laguerreTransform.o \
$(OBJ)lagSphericTransform.o \
$(OBJ)error_handling.o \
$(OBJ)walltimer.o
......@@ -38,7 +37,6 @@ CXXHDR = lagsht_exceptions.h \
laguerreBuilder.h \
laguerreTransform.h \
lagSphericTransform.h \
error_handling.h \
walltimer.h
......
/*
* This file is part of libcxxsupport.
*
* libcxxsupport 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.
*
* libcxxsupport 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 libcxxsupport; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* libcxxsupport is being developed at the Max-Planck-Institut fuer Astrophysik
* and financially supported by the Deutsches Zentrum fuer Luft- und Raumfahrt
* (DLR).
*/
/*
* Utilities for error reporting
*
* Copyright (C) 2003-2011 Max-Planck-Society
* Author: Martin Reinecke
*/
#include "error_handling.h"
using namespace std;
PlanckError::PlanckError(const string &message) : msg (message) {}
PlanckError::PlanckError(const char *message) : msg (message) {}
//virtual
PlanckError::~PlanckError() {}
void planck_failure__(const char *file, int line, const char *func,
const string &msg)
{
cerr << "Error encountered at " << file << ", line " << line << endl;
if (func) cerr << "(function " << func << ")" << endl;
if (msg!="") cerr << endl << msg << endl;
cerr << endl;
}
void planck_failure__(const char *file, int line, const char *func,
const char *msg)
{ planck_failure__ (file,line,func,string(msg)); }
void killjob__()
{ throw; }
/*
* This file is part of libcxxsupport.
*
* libcxxsupport 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.
*
* libcxxsupport 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 libcxxsupport; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* libcxxsupport is being developed at the Max-Planck-Institut fuer Astrophysik
* and financially supported by the Deutsches Zentrum fuer Luft- und Raumfahrt
* (DLR).
*/
/*! \file error_handling.h
* Utilities for error reporting
*
* Copyright (C) 2003-2011 Max-Planck-Society
* Authors: Reinhard Hell, Martin Reinecke
*/
#ifndef PLANCK_ERROR_HANDLING_H
#define PLANCK_ERROR_HANDLING_H
#include <string>
#include <iostream>
#if defined (__GNUC__)
#define PLANCK_FUNC_NAME__ __PRETTY_FUNCTION__
#else
#define PLANCK_FUNC_NAME__ 0
#endif
void planck_failure__(const char *file, int line, const char *func,
const std::string &msg);
void planck_failure__(const char *file, int line, const char *func,
const char *msg);
void killjob__();
class PlanckError
{
private:
std::string msg;
public:
explicit PlanckError(const std::string &message);
explicit PlanckError(const char *message);
virtual const char* what() const
{ return msg.c_str(); }
virtual ~PlanckError();
};
/*! \defgroup errorgroup Error handling */
/*! \{ */
/*! Writes diagnostic output and exits with an error status. */
#define planck_fail(msg) \
do { planck_failure__(__FILE__,__LINE__,PLANCK_FUNC_NAME__,msg); \
throw PlanckError(msg); } while(0)
/*! Throws a PlanckError without diagnostic message. */
#define planck_fail_quietly(msg) \
do { throw PlanckError(msg); } while(0)
/*! Writes diagnostic output and exits with an error status if \a testval
is \a false. */
#define planck_assert(testval,msg) \
do { if (testval); else planck_fail(msg); } while(0)
/*! Macro for improving error diagnostics. Should be placed immediately
after the opening brace of \c main(). Must be used in conjunction with
\c PLANCK_DIAGNOSIS_END. */
#define PLANCK_DIAGNOSIS_BEGIN try {
/*! Macro for improving error diagnostics. Should be placed immediately
before the closing brace of \c main(). Must be used in conjunction with
\c PLANCK_DIAGNOSIS_BEGIN. */
#define PLANCK_DIAGNOSIS_END \
} \
catch (PlanckError &) \
{ killjob__(); /* no need for further diagnostics; they were shown already */ } \
catch (std::exception &e) \
{ std::cerr << "std::exception: " << e.what() << std::endl; killjob__(); } \
catch (...) \
{ std::cerr << "Unknown exception" << std::endl; killjob__(); }
/*! \} */
#endif
......@@ -6,6 +6,7 @@
namespace LagSHT {
class LagSHTError : public std::exception {
public:
explicit LagSHTError(const std::string& m) : msg_(m) { }
......@@ -19,6 +20,11 @@ private:
};//LagSHTError
#define lagsht_assert(testval,msg) \
do { if (testval); else throw LagSHTError(msg); } while(0)
}//end namespace
#endif //LAGSHTEXCEPTIONS_SEEN
......@@ -253,7 +253,7 @@ void MultiSphericalLaguerreTransform() {
}
cout << " >>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<" << endl;
cout << "r_16 Err. Max. " << err_abs << " [" << imax << "], Err. Rel. " << err_rel << endl;
cout << "Err. Max. " << err_abs << " [" << imax << "], Err. Rel. " << err_rel << endl;
cout << " >>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<" << endl;
......
......@@ -36,7 +36,10 @@
#include <algorithm>
#include "walltimer.h"
#include "walltime_c.h"
#include "error_handling.h"
#include "lagsht_exceptions.h" //for assert method
using namespace LagSHT;
//#include "error_handling.h"
using namespace std;
......@@ -169,7 +172,7 @@ void tstack_push(const string &name)
void tstack_pop(const string &name)
{
double t0=wallTime();
planck_assert(curnode && (curnode->name==name), "invalid tstack operation");
lagsht_assert(curnode && (curnode->name==name), "invalid tstack operation");
double t1=wallTime();
curnode->wt.stop(0.5*(t0+t1));
curnode=curnode->parent;
......@@ -178,7 +181,7 @@ void tstack_pop(const string &name)
void tstack_pop()
{
double t0=wallTime();
planck_assert(curnode, "invalid tstack operation");
lagsht_assert(curnode, "invalid tstack operation");
double t1=wallTime();
curnode->wt.stop(0.5*(t0+t1));
curnode=curnode->parent;
......@@ -187,7 +190,7 @@ void tstack_pop()
void tstack_replace(const string &name2)
{
double t0=wallTime();
planck_assert(curnode, "invalid tstack operation");
lagsht_assert(curnode, "invalid tstack operation");
tstack_node *savenode=curnode;
curnode=curnode->parent;
Ti it=curnode->child.find(name2);
......@@ -202,7 +205,7 @@ void tstack_replace(const string &name2)
}
void tstack_replace(const string &name1, const string &name2)
{
planck_assert(curnode && (curnode->name==name1), "invalid tstack operation");
lagsht_assert(curnode && (curnode->name==name1), "invalid tstack operation");
tstack_replace(name2);
}
......@@ -211,7 +214,7 @@ void tstack_report(const string &stem)
const tstack_node *ptr = 0;
for (Tci it=tstack_root.child.begin(); it!=tstack_root.child.end(); ++it)
if (it->first==stem) ptr=&(it->second);
planck_assert(ptr,"invalid stem");
lagsht_assert(ptr,"invalid stem");
int slen=string("<unaccounted>").size();
slen = max(slen,ptr->max_namelen());
......
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