From 508fc1b5ec0df20e57bfcc23e22d54c3c79e2d0b Mon Sep 17 00:00:00 2001 From: David Perez Date: Thu, 12 Mar 2015 15:30:43 +0100 Subject: [PATCH 1/4] Issue 1900, more robustness in help system --- main/command/src/main/scala/sbt/BasicCommands.scala | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/main/command/src/main/scala/sbt/BasicCommands.scala b/main/command/src/main/scala/sbt/BasicCommands.scala index 3310158b8..36072ecc6 100644 --- a/main/command/src/main/scala/sbt/BasicCommands.scala +++ b/main/command/src/main/scala/sbt/BasicCommands.scala @@ -27,7 +27,10 @@ object BasicCommands { def helpParser(s: State) = { - val h = (Help.empty /: s.definedCommands)(_ ++ _.help(s)) + val h = (Help.empty /: s.definedCommands) { (a, b) ⇒ + a ++ + (try b.help(s) catch { case ex: Throwable ⇒ Help.empty }) + } val helpCommands = h.detail.keySet val spacedArg = singleArgument(helpCommands).? applyEffect(spacedArg)(runHelp(s, h)) @@ -35,7 +38,12 @@ object BasicCommands { def runHelp(s: State, h: Help)(arg: Option[String]): State = { - val message = Help.message(h, arg) + val message = try + Help.message(h, arg) + catch { + case ex: Throwable ⇒ + ex.toString + } System.out.println(message) s } From 79ef77221954e2f8f5dd8bbb2d1b166b55b8f139 Mon Sep 17 00:00:00 2001 From: David Perez Date: Tue, 24 Mar 2015 14:54:10 +0100 Subject: [PATCH 2/4] Removed unicode arrow --- main/command/src/main/scala/sbt/BasicCommands.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/command/src/main/scala/sbt/BasicCommands.scala b/main/command/src/main/scala/sbt/BasicCommands.scala index 36072ecc6..6338c6b5d 100644 --- a/main/command/src/main/scala/sbt/BasicCommands.scala +++ b/main/command/src/main/scala/sbt/BasicCommands.scala @@ -29,7 +29,7 @@ object BasicCommands { { val h = (Help.empty /: s.definedCommands) { (a, b) ⇒ a ++ - (try b.help(s) catch { case ex: Throwable ⇒ Help.empty }) + (try b.help(s) catch { case ex: Throwable => Help.empty }) } val helpCommands = h.detail.keySet val spacedArg = singleArgument(helpCommands).? From 2c52efeca5675eca6cefe9e3b8a22468a747781b Mon Sep 17 00:00:00 2001 From: David Perez Date: Wed, 25 Mar 2015 13:14:48 +0100 Subject: [PATCH 3/4] Removed unicode arrow --- main/command/src/main/scala/sbt/BasicCommands.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main/command/src/main/scala/sbt/BasicCommands.scala b/main/command/src/main/scala/sbt/BasicCommands.scala index 6338c6b5d..50cabf7cd 100644 --- a/main/command/src/main/scala/sbt/BasicCommands.scala +++ b/main/command/src/main/scala/sbt/BasicCommands.scala @@ -27,7 +27,7 @@ object BasicCommands { def helpParser(s: State) = { - val h = (Help.empty /: s.definedCommands) { (a, b) ⇒ + val h = (Help.empty /: s.definedCommands) { (a, b) => a ++ (try b.help(s) catch { case ex: Throwable => Help.empty }) } @@ -41,7 +41,7 @@ object BasicCommands { val message = try Help.message(h, arg) catch { - case ex: Throwable ⇒ + case ex: Throwable => ex.toString } System.out.println(message) From 5ce11c67c54190d7137b91f8f5289113e4b547d4 Mon Sep 17 00:00:00 2001 From: David Perez Date: Wed, 25 Mar 2015 15:02:45 +0100 Subject: [PATCH 4/4] Catch exceptions with NonFatal --- main/command/src/main/scala/sbt/BasicCommands.scala | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main/command/src/main/scala/sbt/BasicCommands.scala b/main/command/src/main/scala/sbt/BasicCommands.scala index 50cabf7cd..caab8ea5c 100644 --- a/main/command/src/main/scala/sbt/BasicCommands.scala +++ b/main/command/src/main/scala/sbt/BasicCommands.scala @@ -13,6 +13,8 @@ import BasicKeys._ import java.io.File +import scala.util.control.NonFatal + object BasicCommands { lazy val allBasicCommands = Seq(nop, ignore, help, completionsCommand, multi, ifLast, append, setOnFailure, clearOnFailure, stashOnFailure, popOnFailure, reboot, call, early, exit, continuous, history, shell, read, alias) ++ compatCommands @@ -29,7 +31,7 @@ object BasicCommands { { val h = (Help.empty /: s.definedCommands) { (a, b) => a ++ - (try b.help(s) catch { case ex: Throwable => Help.empty }) + (try b.help(s) catch { case NonFatal(ex) => Help.empty }) } val helpCommands = h.detail.keySet val spacedArg = singleArgument(helpCommands).? @@ -41,7 +43,7 @@ object BasicCommands { val message = try Help.message(h, arg) catch { - case ex: Throwable => + case NonFatal(ex) => ex.toString } System.out.println(message)