Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

Commit

Permalink
Issue #27: change non-zero return codes to exceptions (#50)
Browse files Browse the repository at this point in the history
* Issue #27: change return code in Dotify to exception (also in Main)

* Line 45, I replaced return 1 by throw e in Main.scala

* in file MBT.scala, several System.exit(1) replaced by throw(error)

* in file MBT.scala, System.exit changed by throw

	new file:   src/main/java/modbat/mbt/NoTransitionException.java
	modified:   src/main/scala/modbat/mbt/MBT.scala
	modified:   src/main/scala/modbat/mbt/Dotify.scala
	modified:   src/main/scala/modbat/mbt/Main.scala
  • Loading branch information
AlexandreFournel authored and cyrille-artho committed May 15, 2019
1 parent 8c0f4f1 commit 5e59453
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ build
git-hash
*.tar.gz
.*.swp
.DS_Store

# Gradle
.gradle/
Expand Down
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);
}
}
5 changes: 3 additions & 2 deletions src/main/scala/modbat/mbt/MBT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ object MBT {
} catch {
case e: ClassNotFoundException => {
Log.error("Class \"" + className + "\" not found.")
System.exit(1)
throw e
}
}
}
Expand Down 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 5e59453

Please sign in to comment.