Chaste Commit::ca8ccdedf819b6e02855bc0e8e6f50bdecbc5208
|
#include <string>
#include <sstream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <exception>
#include <boost/preprocessor/stringize.hpp>
Go to the source code of this file.
Classes | |
class | Exception |
Macros | |
#define | EXCEPTION(message) |
#define | EXCEPT_IF_NOT(test) if (!(test)) EXCEPTION("Assertion tripped: " BOOST_PP_STRINGIZE(test)) |
#define | EXCEPT_IF(test) if (test) EXCEPTION("Assertion tripped: " BOOST_PP_STRINGIZE(test)) |
#define | TERMINATE(message) |
#define | NEVER_REACHED TERMINATE("Should have been impossible to reach this line of code"); exit(EXIT_FAILURE) |
#define | UNUSED_OPT(var) |
#define | ABORT_IF_THROWS(block) |
#define | EXPECT0(cmd, arg) |
#define | ABORT_IF_NON0_WITH_MSG(retcode, msg) |
#define | ABORT_IF_NON0(cmd, arg) |
#define | EXPECT_NON0(cmd, arg) |
#define | IGNORE_RET(cmd, arg) |
Variables | |
const unsigned | UNSIGNED_UNSET = UINT_MAX |
const int | INT_UNSET = INT_MAX |
const double | DOUBLE_UNSET = DBL_MAX |
Contains the Exception class, along with some macros that are widely used throughout the code.
Definition in file Exception.hpp.
#define ABORT_IF_NON0 | ( | cmd, | |
arg | |||
) |
Handy for calling functions like system which return non-zero on error. Terminate if an error occurs.
This macro should be used instead of EXPECT0 within blocks that are only executed by one process, but need to kill all processes if an error occurs.
cmd | command to call |
arg | its argument (will be converted to std::string) |
Definition at line 308 of file Exception.hpp.
#define ABORT_IF_NON0_WITH_MSG | ( | retcode, | |
msg | |||
) |
Handy for calling functions like system which return non-zero on error. Terminate if the return code is non-zero, printing a suitable message.
retcode | command return code |
msg | error message to display |
Definition at line 291 of file Exception.hpp.
#define ABORT_IF_THROWS | ( | block | ) |
Convenience function to convert an exception thrown by a single process into termination of the entire program.
block | the block of code to execute |
Definition at line 246 of file Exception.hpp.
#define EXCEPT_IF | ( | test | ) | if (test) EXCEPTION("Assertion tripped: " BOOST_PP_STRINGIZE(test)) |
Convenience macro for the opposite truth condition as EXCEPT_IF_NOT.
test | the test that must always be false. |
Definition at line 179 of file Exception.hpp.
#define EXCEPT_IF_NOT | ( | test | ) | if (!(test)) EXCEPTION("Assertion tripped: " BOOST_PP_STRINGIZE(test)) |
Convenience macro for changing an assert into an exception - has the same calling semantics, but throws.
test | the test that must always be true. |
Definition at line 171 of file Exception.hpp.
#define EXCEPTION | ( | message | ) |
Convenience macro for throwing an exception, in order to add file and line info.
message | the error message to use, as a streamed expression |
Definition at line 156 of file Exception.hpp.
#define EXPECT0 | ( | cmd, | |
arg | |||
) |
Handy for calling functions like system which return non-zero on error. Throws if an error occurs.
cmd | command to call |
arg | its argument (will be converted to std::string) |
Definition at line 275 of file Exception.hpp.
#define EXPECT_NON0 | ( | cmd, | |
arg | |||
) |
Handy for calling functions like system which return non-zero on error. This time we expect failure; throws if the command succeeds.
cmd | command to call |
arg | its argument (will be converted to std::string) |
Definition at line 322 of file Exception.hpp.
#define IGNORE_RET | ( | cmd, | |
arg | |||
) |
Handy for calling functions like system which return non-zero on error. This version ignores the return code, in case you don't care about errors for some reason...
cmd | command to call |
arg | its argument (will be converted to std::string) |
Definition at line 337 of file Exception.hpp.
#define NEVER_REACHED TERMINATE("Should have been impossible to reach this line of code"); exit(EXIT_FAILURE) |
Use for control paths that will never be executed, just to make sure they aren't.
The exit statement at the end of NEVER_REACHED is not really needed but prevents g++ from complaining about uninitialised variables when you have code that looks like:
relative_to is considered potentially uninitialised in the default branch unless the compiler finds a exit, assert or throw statement.
Definition at line 227 of file Exception.hpp.
#define TERMINATE | ( | message | ) |
Terminate execution safely, even when running in parallel. Use for level 4 errors: execution cannot continue from this point and hence should be terminated (even when running with NDEBUG).
message | explanatory message |
Definition at line 189 of file Exception.hpp.
#define UNUSED_OPT | ( | var | ) |
This is to cope with NDEBUG causing variables to not be used, when they are only used in assert()s.
var | the "unused" variable |
Definition at line 237 of file Exception.hpp.
const double DOUBLE_UNSET = DBL_MAX |
Use when initialising a double variable that doesn't have a sensible default value.
Definition at line 57 of file Exception.hpp.
Referenced by ImmersedBoundaryPalisadeMeshGenerator::ImmersedBoundaryPalisadeMeshGenerator(), OffLatticeRandomFieldGenerator< SPACE_DIM >::OffLatticeRandomFieldGenerator(), QuadraturePointsGroup< DIM >::QuadraturePointsGroup(), CellProperties::CalculateActionPotentialDurations(), AbstractCvodeCell::Compute(), ImmersedBoundaryMesh< ELEMENT_DIM, SPACE_DIM >::DivideElement(), ImmersedBoundaryMesh< ELEMENT_DIM, SPACE_DIM >::GetAverageNodeSpacingOfElement(), ImmersedBoundaryMesh< ELEMENT_DIM, SPACE_DIM >::GetAverageNodeSpacingOfLamina(), AbstractCellWriter< ELEMENT_DIM, SPACE_DIM >::GetCellDataForVtkOutput(), CellCycleModelOdeHandler::GetDt(), AbstractCvodeCellWithDataClamp::GetExperimentalVoltageAtTimeT(), AbstractOdeBasedCellCycleModel::GetOdeStopTime(), AbstractOdeBasedPhaseBasedCellCycleModel::GetOdeStopTime(), SimulationTime::GetTime(), AbstractCellWriter< ELEMENT_DIM, SPACE_DIM >::GetVectorCellDataForVtkOutput(), CellAppliedForceWriter< ELEMENT_DIM, SPACE_DIM >::GetVectorCellDataForVtkOutput(), SimulationTime::IsStartTimeSetUp(), SimulationTime::ResetEndTimeAndNumberOfTimeSteps(), SimulationTime::SetEndTimeAndNumberOfTimeSteps(), Kerchoffs2003ContractionModel::SetInputParameters(), Nash2004ContractionModel::SetInputParameters(), NhsContractionModel::SetInputParameters(), SimulationTime::SetStartTime(), AbstractCvodeCell::SolveAndUpdateState(), LinearParabolicPdeSystemWithCoupledOdeSystemSolver< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM >::SolveAndWriteResultsToFile(), ContactInhibitionCellCycleModel::UpdateCellCyclePhase(), NormallyDistributedTargetAreaModifier< DIM >::UpdateTargetAreaOfCell(), SimpleTargetAreaModifier< DIM >::UpdateTargetAreaOfCell(), TargetAreaLinearGrowthModifier< DIM >::UpdateTargetAreaOfCell(), AbstractHdf5Converter< ELEMENT_DIM, SPACE_DIM >::WriteInfoFile(), and ImmersedBoundaryCellPopulation< DIM >::WriteVtkResultsToFile().
const int INT_UNSET = INT_MAX |
Use when initialising an int variable that doesn't have a sensible default value.
Definition at line 55 of file Exception.hpp.
const unsigned UNSIGNED_UNSET = UINT_MAX |
Use when initialising an unsigned variable that doesn't have a sensible default value.
Definition at line 53 of file Exception.hpp.
Referenced by CellId::CellId(), CellProperties::CalculateActionPotentialDurations(), ExclusionCaBasedDivisionRule< SPACE_DIM >::CalculateDaughterNodeIndex(), ShovingCaBasedDivisionRule< SPACE_DIM >::CalculateDaughterNodeIndex(), CardiacElectroMechanicsProblem< DIM, ELEC_PROB_DIM >::DetermineWatchedNodes(), NodePartitioner< ELEMENT_DIM, SPACE_DIM >::GeometricPartitioning(), Cell::GetAncestor(), CellAncestorWriter< ELEMENT_DIM, SPACE_DIM >::GetCellDataForVtkOutput(), CellId::GetCellId(), VertexMesh< ELEMENT_DIM, SPACE_DIM >::GetDelaunayNodeIndexCorrespondingToVoronoiElementIndex(), CellId::GetMaxCellId(), VertexMesh< ELEMENT_DIM, SPACE_DIM >::GetVoronoiElementIndexCorrespondingToDelaunayNodeIndex(), SimpleWntCellCycleModel::GetWntType(), CellCycleModelOdeSolver< CELL_CYCLE_MODEL, BackwardEulerIvpOdeSolver >::Initialise(), CellCycleModelOdeSolver< CELL_CYCLE_MODEL, BackwardEulerIvpOdeSolver >::IsSetUp(), AbstractHdf5Converter< ELEMENT_DIM, SPACE_DIM >::MoveOntoNextDataset(), CellCycleModelOdeSolver< CELL_CYCLE_MODEL, BackwardEulerIvpOdeSolver >::Reset(), AbstractConductivityModifier< ELEMENT_DIM, SPACE_DIM >::rGetModifiedConductivityTensor(), AbstractCellCycleModel::SetDimension(), CardiacElectroMechanicsProblem< DIM, ELEC_PROB_DIM >::Solve(), MutableMesh< ELEMENT_DIM, SPACE_DIM >::SplitEdge(), and CellAncestorWriter< ELEMENT_DIM, SPACE_DIM >::VisitCell().