From 6e50429ec3c147beae0eb46e8558340dfa9be1f4 Mon Sep 17 00:00:00 2001
From: "Emmanouil (Manos) Koukoutos" <emmanouil.koukoutos@epfl.ch>
Date: Wed, 9 Jul 2014 16:04:00 +0200
Subject: [PATCH] Catch error when processing options

---
 src/main/scala/leon/Main.scala | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/src/main/scala/leon/Main.scala b/src/main/scala/leon/Main.scala
index f2cba94b7..3cac21a4d 100644
--- a/src/main/scala/leon/Main.scala
+++ b/src/main/scala/leon/Main.scala
@@ -228,7 +228,24 @@ object Main {
     }
 
     // Process options
-    val ctx = processOptions(realArgs)
+    val ctx = try {
+      processOptions(realArgs)
+    } catch {
+      case LeonFatalError(None) =>
+        sys.exit(1)
+
+      case LeonFatalError(Some(msg)) =>
+        // For the special case of fatal errors not sent though Reporter, we
+        // send them through reporter one time
+        try {
+          new DefaultReporter(Settings()).fatalError(msg)
+        } catch {
+          case _: LeonFatalError =>
+        }
+
+        sys.exit(1)
+    }
+
 
     try {
       ctx.interruptManager.registerSignalHandler()
-- 
GitLab