architecture-building-systems / revitpythonshell

An IronPython scripting environment for Autodesk Revit and Vasari
MIT License
494 stars 113 forks source link

Uncaught error in the console on R2015 - console becomes irresponsive to shortcuts #33

Open daren-thomas opened 8 years ago

daren-thomas commented 8 years ago

When running code in the console on R2015 or 2016, if there is an uncaught error then the console becomes irresponsive to shortcuts (save, run, copy, paste etc). It essentially means you need to close the console, re-open, re-load your script to carry on working with ease.

PMoureu commented 8 years ago

Hi Daren, i found something to avoid errors and crashes, with ExecuteAndWrap maybe it can replace the first test too ?(var command = scriptSource.Compile(errors);)

                {
                    executing = true;
                    var errors = new ErrorReporter();

                    var command = scriptSource.Compile(errors);
                    if (command == null)
                    {
                        // compilation failed
                        error = "Syntax Error: " + string.Join("\nSyntax Error: ", errors.Errors) + "\n";
                    }
                    else
                    {
                        var harderrors = new ErrorReporter();
                        var h_error = new ObjectHandle(harderrors);
                        GetCommandDispatcher()(() => scriptSource.ExecuteAndWrap(commandLine.ScriptScope, out h_error));
                        if (h_error != null)
                        {
                            error = harderrors.Errors + "\n";
                        }
                    }                    
                }
daren-thomas commented 8 years ago

Hi @PMoureu,

could you please post a pull request?

Thank you!