import cmd
import readline

class Shell(cmd.Cmd):
    def __init__(self, server):
        cmd.Cmd.__init__(self)
        self.server = server

    def preloop(self):
        self.intro = "Graphene 0.1"
        self.prompt = "> "
        self.completekey = "Tab"

    def do_help(self, line):
        # Help message.
        # TODO: Actually be helpful
        pass

    def do_EOF(self, line):
        return True

    def emptyline(self):
        # On empty line, don't do anything at all
        pass

    def default(self, line):
        try:
            if not self.server.doCommands(line):
                return True
        except Exception, e:
            print "Error: %s" % e

@@ -19,16 +19,44 @@
 readline
+%0Aimport traceback%0Aimport sys
 %0A%0Aclass 
@@ -517,32 +517,644 @@
 l%0A        pass%0A%0A
+    def format_traceback(self, err_type, err_value, tb):%0A        full_tb = traceback.extract_tb(tb)%0A        s = %22%25s: %25s%5Cn%25s%25s STACK TRACE %25s%22 %25 (err_type.__name__, err_value,%0A            %22 %22 * len(self.prompt), %22=%22 * 30, %22=%22 * 30)%0A        for t in full_tb:%0A            file_name, lineno, fn, line = t%0A            module_name = file_name.replace(%22/%22,%22.%22).replace(%22.py%22,%22%22)%0A            s += %22%5Cn%25sIn %25s.%25s, line %25d:%5Cn%25s%25s%22 %25 (%22 %22 * len(self.prompt),%0A                module_name, fn, lineno, %22 %22 * (4 + len(self.prompt)), line)%0A        s += %22%5Cn%25s%25s%22 %25 (%22 %22 * len(self.prompt), %22=%22 * (2 * 30 + 13))%0A        return s%0A%0A
     def default(
@@ -1274,21 +1274,8 @@
 cept
- Exception, e
 :%0A  
@@ -1294,20 +1294,74 @@
 int 
-%22Error: %25s%22 %25 e
+self.format_traceback(sys.exc_type, sys.exc_value, sys.exc_traceback)
 %0A

Update shell to show better information on errors.