Skip to content

Commit

Permalink
Issue cyrille-artho#27: change exit to exception.
Browse files Browse the repository at this point in the history
	new file:   src/main/java/modbat/mbt/NoTransitionException.java
	modified:   src/main/scala/modbat/mbt/MBT.scala
  • Loading branch information
Alexandre Fournel committed May 15, 2019
1 parent cadf453 commit e2d5593
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/main/java/modbat/mbt/NoTransitionException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package modbat.mbt;

class NoTransitionsException extends Exception {
NoTransitionsException(String message) {
super(message);
}
}
3 changes: 2 additions & 1 deletion src/main/scala/modbat/mbt/MBT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -301,12 +301,13 @@ object MBT {
// if modelInstance == null: initial model
def launch(modelInstance: Model): MBT = {
val model = mkModel(modelInstance)

if (Transition.pendingTransitions.isEmpty) {
Log.error("Model " + model.getClass.getName + " has no transitions.")
Log.error("Make sure at least one transition exists of type")
Log.error(" \"a\" -> \"b\" := { code } // or, for an empty transition:")
Log.error(" \"a\" -> \"b\" := skip")
System.exit(1)
throw new NoTransitionsException(model.getClass.getName)
}
val inst = new MBT(model, Transition.getTransitions)
Transition.clear
Expand Down

0 comments on commit e2d5593

Please sign in to comment.