felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r1779309 - /felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Shell.java
Date Wed, 18 Jan 2017 10:14:47 GMT
Author: gnodet
Date: Wed Jan 18 10:14:47 2017
New Revision: 1779309

URL: http://svn.apache.org/viewvc?rev=1779309&view=rev
Log:
[FELIX-5498] [gogo][jline] The shell should display exception thrown from commands

Modified:
    felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Shell.java

Modified: felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Shell.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Shell.java?rev=1779309&r1=1779308&r2=1779309&view=diff
==============================================================================
--- felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Shell.java (original)
+++ felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Shell.java Wed Jan 18
10:14:47 2017
@@ -63,6 +63,8 @@ import org.jline.reader.impl.LineReaderI
 import org.jline.terminal.Terminal;
 import org.jline.terminal.Terminal.Signal;
 import org.jline.terminal.Terminal.SignalHandler;
+import org.jline.utils.AttributedStringBuilder;
+import org.jline.utils.AttributedStyle;
 
 public class Shell {
 
@@ -420,6 +422,12 @@ public class Shell {
                             System.out.println(session.format(result, Converter.INSPECT));
                         }
                     } catch (Exception e) {
+                        AttributedStringBuilder sb = new AttributedStringBuilder();
+                        sb.style(sb.style().foreground(AttributedStyle.RED));
+                        sb.append(e.toString());
+                        sb.style(sb.style().foregroundDefault());
+                        terminal.writer().println(sb.toAnsi(terminal));
+                        terminal.flush();
                         session.put(Shell.VAR_EXCEPTION, e);
                     }
 



Mime
View raw message