Browse Source

Replaced assert(false) by throwing an exception

tempestpy_adaptions
Matthias Volk 5 years ago
parent
commit
7fb660227f
  1. 15
      src/storm-gspn/adapters/XercesAdapter.h
  2. 7
      src/storm-pgcl/builder/JaniProgramGraphBuilder.cpp
  3. 7
      src/storm/analysis/GraphConditions.cpp
  4. 2
      src/storm/storage/jani/JSONExporter.cpp
  5. 4
      src/storm/utility/shortestPaths.cpp

15
src/storm-gspn/adapters/XercesAdapter.h

@ -10,7 +10,8 @@
#include <xercesc/sax/HandlerBase.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#include "storm/utility/macros.h"
#include "storm/exceptions/IllegalArgumentException.h"
namespace storm {
namespace adapters {
@ -27,16 +28,12 @@ namespace storm {
auto elementNode = (xercesc::DOMElement *) node;
return XMLtoString(elementNode->getTagName());
}
case xercesc::DOMNode::NodeType::TEXT_NODE: {
case xercesc::DOMNode::NodeType::TEXT_NODE:
return XMLtoString(node->getNodeValue());
}
case xercesc::DOMNode::NodeType::ATTRIBUTE_NODE: {
case xercesc::DOMNode::NodeType::ATTRIBUTE_NODE:
return XMLtoString(node->getNodeName());
}
default: {
assert(false);
return "";
}
default:
STORM_LOG_THROW(false, storm::exceptions::IllegalArgumentException, "Unknown DOMNode type");
}
}
}

7
src/storm-pgcl/builder/JaniProgramGraphBuilder.cpp

@ -1,6 +1,7 @@
#include "JaniProgramGraphBuilder.h"
#include "storm/storage/jani/EdgeDestination.h"
#include "storm/exceptions/NotSupportedException.h"
namespace storm {
namespace builder {
@ -23,12 +24,10 @@ namespace storm {
variables.emplace(v.first, janiVar);
automaton.addVariable(*janiVar);
} else {
// Not yet supported.
assert(false);
STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Unbounded right bound is not supported yet");
}
} else {
// Not yet supported.
assert(false);
STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Unbounded left bound is not supported yet");
}
} else {
storm::jani::UnboundedIntegerVariable* janiVar = new storm::jani::UnboundedIntegerVariable(v.second.getName(), v.second, programGraph.getInitialValue(v.first), isRewardVariable(v.first));

7
src/storm/analysis/GraphConditions.cpp

@ -4,6 +4,7 @@
#include "GraphConditions.h"
#include "storm/utility/constants.h"
#include "storm/exceptions/NotImplementedException.h"
#include "storm/exceptions/UnexpectedException.h"
#include "storm/models/sparse/StandardRewardModel.h"
namespace storm {
@ -44,7 +45,7 @@ namespace storm {
} else if (entry.denominator().constantPart() < 0) {
wellformedConstraintSet.emplace(entry.nominator().polynomialWithCoefficient(), storm::CompareRelation::LEQ);
} else {
assert(false); // Should fail before.
STORM_LOG_THROW(false, storm::exceptions::UnexpectedException, "Should have failed before.");
}
} else {
wellformedConstraintSet.emplace(entry.denominator().polynomialWithCoefficient(), storm::CompareRelation::NEQ);
@ -111,7 +112,7 @@ namespace storm {
} else if (transition.getValue().denominator().constantPart() < 0) {
wellformedConstraintSet.emplace(transition.getValue().nominator().polynomialWithCoefficient(), storm::CompareRelation::LEQ);
} else {
assert(false); // Should fail before.
STORM_LOG_THROW(false, storm::exceptions::UnexpectedException, "Should have failed before.");
}
} else {
wellformedConstraintSet.emplace(transition.getValue().denominator().polynomialWithCoefficient(), storm::CompareRelation::NEQ);
@ -147,7 +148,7 @@ namespace storm {
} else if (entry.getValue().denominator().constantPart() < 0) {
wellformedConstraintSet.emplace(entry.getValue().nominator().polynomialWithCoefficient(), storm::CompareRelation::LEQ);
} else {
assert(false); // Should fail before.
STORM_LOG_THROW(false, storm::exceptions::UnexpectedException, "Should have failed before.");
}
} else {
wellformedConstraintSet.emplace(entry.getValue().denominator().polynomialWithCoefficient(), storm::CompareRelation::NEQ);

2
src/storm/storage/jani/JSONExporter.cpp

@ -796,7 +796,7 @@ namespace storm {
typeDescr["kind"] = "array";
typeDescr["base"] = buildTypeDescription(type.getElementType());
} else {
assert(false);
STORM_LOG_THROW(false, storm::exceptions::IllegalArgumentException, "Unknown expression type.");
}
return typeDescr;
}

4
src/storm/utility/shortestPaths.cpp

@ -9,6 +9,7 @@
#include "storm/utility/graph.h"
#include "storm/utility/macros.h"
#include "storm/utility/shortestPaths.h"
#include "storm/exceptions/UnexpectedException.h"
// FIXME: I've accidentally used k=0 *twice* now without realizing that k>=1 is required!
// (Also, did I document this? I think so, somewhere. I went with k>=1 because
@ -247,8 +248,7 @@ namespace storm {
// there is no such edge
// let's disallow that for now, because I'm not expecting it to happen
assert(false);
return zero<T>();
STORM_LOG_THROW(false, storm::exceptions::UnexpectedException, "Should not happen.");
} else {
// edge must be "virtual edge" to meta-target
assert(isMetaTargetPredecessor(tailNode));

Loading…
Cancel
Save