Author: rareddy
Date: 2009-08-24 17:11:47 -0400 (Mon, 24 Aug 2009)
New Revision: 1275
Modified:
trunk/adminshell/src/main/resources/scripts/jdbc.bsh
trunk/adminshell/src/main/resources/scripts/server.bsh
trunk/adminshell/src/main/resources/scripts/util.bsh
Log:
TEIID-224: fixing display of exception traces in the admin shell in certain situations.
Modified: trunk/adminshell/src/main/resources/scripts/jdbc.bsh
===================================================================
--- trunk/adminshell/src/main/resources/scripts/jdbc.bsh 2009-08-24 21:09:24 UTC (rev
1274)
+++ trunk/adminshell/src/main/resources/scripts/jdbc.bsh 2009-08-24 21:11:47 UTC (rev
1275)
@@ -198,10 +198,8 @@
}
}
-private boolean interactive() {
- return
this.interpreter.get("bsh.interactive").toString().equals("true");
-}
+
int FETCHSIZE=1000;
int MAXROWS=500;
Modified: trunk/adminshell/src/main/resources/scripts/server.bsh
===================================================================
--- trunk/adminshell/src/main/resources/scripts/server.bsh 2009-08-24 21:09:24 UTC (rev
1274)
+++ trunk/adminshell/src/main/resources/scripts/server.bsh 2009-08-24 21:11:47 UTC (rev
1275)
@@ -46,7 +46,9 @@
currentContext().internalAdmin =
createExceptionHandlingProxy(mmConn.getAdminAPI());
return mmConn;
} catch(e) {
+ parentContext();
print("Failed to connect: {"+e.getMessage()+"}");
+ debug(e);
return null;
}
}
@@ -82,18 +84,18 @@
if (MMURL.isValidServerURL(url)) {
String contextName = genConnectionName();
newContext(contextName);
-
- //url is in "server URL format": connect via ServerAdminFactory
- currentContext().internalAdmin =
createExceptionHandlingProxy(ServerAdminFactory.getInstance().createAdmin(username,
password.toCharArray(), url));
- currentContext().internalPrompt =
currentConnectionName()+"["+url+"] $ ";
-
+ try {
+ //url is in "server URL format": connect via ServerAdminFactory
+ currentContext().internalAdmin =
createExceptionHandlingProxy(ServerAdminFactory.getInstance().createAdmin(username,
password.toCharArray(), url));
+ currentContext().internalPrompt =
currentConnectionName()+"["+url+"] $ ";
+ } catch(e) {
+ parentContext();
+ print("Failed to connect: {"+e.getMessage()+"}");
+ debug(e);
+ return null;
+ }
} else {
- String contextName = genConnectionName();
- newContext(contextName);
-
- //url is in "jdbc URL format": connect via MMServerConnection
- currentContext().internalConnection =
connectDriver("org.teiid.jdbc.TeiidDriver", url, username, password);
- currentContext().internalAdmin =
createExceptionHandlingProxy(currentContext().internalConnection.getAdminAPI());
+ print("Wrong syntax for the URL.. connection failed.");
}
}
Modified: trunk/adminshell/src/main/resources/scripts/util.bsh
===================================================================
--- trunk/adminshell/src/main/resources/scripts/util.bsh 2009-08-24 21:09:24 UTC (rev
1274)
+++ trunk/adminshell/src/main/resources/scripts/util.bsh 2009-08-24 21:11:47 UTC (rev
1275)
@@ -129,7 +129,13 @@
for (Object object:msg) {
print(object);
}
- } else {
+ }
+ else if (msg instanceof Throwable) {
+ StringWriter sw = new StringWriter();
+ msg.printStackTrace(new PrintWriter(sw));
+ print(sw.getBuffer().toString());
+ }
+ else {
print(msg);
}
}
@@ -180,9 +186,13 @@
while (ex instanceof InvocationTargetException) {
ex = e.getTargetException();
}
- if (ex instanceof AdminException) {
+ if (interactive()) {
print("Error:"+ex.getMessage());
+ debug(ex);
}
+ else {
+ throw ex;
+ }
} catch(Throwable t) {
msg = t.getMessage();
if (msg != null) {
@@ -197,6 +207,10 @@
return Proxy.newProxyInstance(obj.getClass().getClassLoader(),
obj.getClass().getInterfaces(), new ExceptionHandler(obj));
}
+boolean interactive() {
+ return
this.interpreter.get("bsh.interactive").toString().equals("true");
+}
+
quit(){
exit();
}
Show replies by thread