FPGA-Research-Manchester / FABulous

Fabric generator and CAD tools
https://fabulous.readthedocs.io/en/latest/
Apache License 2.0
142 stars 31 forks source link

Print traceback on error inside FABulous Shell #152

Closed mole99 closed 4 months ago

mole99 commented 4 months ago

If an error/exception occurs inside the FABulous Shell it is not printed, only False is returned:

    def onecmd(self, line):
        try:
            return super().onecmd(line)
        except:
            return False

You can easily test this by adding a syntax error to e.g. the do_load_fabric function:

    def do_load_fabric(self, args=""):
        "load csv file and generate an internal representation of the fabric"
        args = self.parse(args)
        asdf
        ....

The FABulous shell does not indicate that an error has occurred:

FABulous> load_fabric
FABulous> 

This PR fixes that:

FABulous> load_fabric
Traceback (most recent call last):
  File "/home/leo/Projects/FABulous_fix/FABulous.py", line 276, in onecmd
    return super().onecmd(line)
           ^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/cmd.py", line 217, in onecmd
    return func(arg)
           ^^^^^^^^^
  File "/home/leo/Projects/FABulous_fix/FABulous.py", line 318, in do_load_fabric
    asdf
NameError: name 'asdf' is not defined

FABulous> 
IAmMarcelJung commented 4 months ago

Nice! This should fix #148.

mole99 commented 4 months ago

Thanks for linking the issue! I haven't even seen it ^^