Guillaume Nodet created FELIX-5637:
--------------------------------------

             Summary: [gogo][runtime] Error throwns by commands are swallowed 
and lost
                 Key: FELIX-5637
                 URL: https://issues.apache.org/jira/browse/FELIX-5637
             Project: Felix
          Issue Type: Bug
          Components: Gogo Runtime
            Reporter: Guillaume Nodet


{code}
diff --git 
a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandProcessorImpl.java
 
b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandProcessorImpl.java
index 451a1c8f0..b227d72c5 100644
--- 
a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandProcessorImpl.java
+++ 
b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandProcessorImpl.java
@@ -23,6 +23,7 @@ import java.io.OutputStream;
 import java.lang.reflect.Method;
 import java.util.Collections;
 import java.util.LinkedHashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
@@ -147,6 +148,18 @@ public class CommandProcessorImpl implements 
CommandProcessor
         String cfunction = name.substring(colon);
         boolean anyScope = (colon == 1 && name.charAt(0) == '*');
 
+        // HACK: testing errors
+        System.out.println("NAME: " + name);
+        if (name.equals("*:error")) {
+            return new Function() {
+                @Override
+                public Object execute(CommandSession session, List<Object> 
arguments) throws Exception {
+                    System.out.println("THROWING ERROR");
+                    throw new Error("OOPS");
+                }
+            };
+        }
+
         Map<Object, Integer> cmdMap = commands.get(name);
 
         if (null == cmdMap && anyScope)
{code}

and then in the jline3 demo:

{code}
g! error                                                                        
                                                                                
                                                                                
                                                      14:27:05
NAME: *:error
THROWING ERROR
g! 
{code}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to