From 508fc1b5ec0df20e57bfcc23e22d54c3c79e2d0b Mon Sep 17 00:00:00 2001 From: David Perez Date: Thu, 12 Mar 2015 15:30:43 +0100 Subject: [PATCH 1/5] 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/5] 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/5] 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/5] 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) From 3159ce1063affd5528a4613ca549c27e8d4dc3fc Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 25 Mar 2015 18:11:36 -0400 Subject: [PATCH 5/5] Adds note to on #1940 --- notes/0.13.9/help.markdown | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 notes/0.13.9/help.markdown diff --git a/notes/0.13.9/help.markdown b/notes/0.13.9/help.markdown new file mode 100644 index 000000000..dd4d875be --- /dev/null +++ b/notes/0.13.9/help.markdown @@ -0,0 +1,16 @@ + [@cunei]: https://github.com/cunei + [@eed3si9n]: https://github.com/eed3si9n + [@gkossakowski]: https://github.com/gkossakowski + [@jsuereth]: https://github.com/jsuereth + [@DavidPerezIngeniero]: https://github.com/DavidPerezIngeniero + + [1900]: https://github.com/sbt/sbt/issues/1900 + [1940]: https://github.com/sbt/sbt/pull/1940 + +### Changes with compatibility implications + +### Improvements + +### Fixes + +- Captures errors on `help` command. [#1900][1900]/[#1940][1940] by [@DavidPerezIngeniero][@DavidPerezIngeniero]