Error checking the SimpleSubroutine project

Posted by Friday, July 15, 2016 4:03:00 PM Categories: basics c# Easy Freedom Script Windows
Rate this Content 1 Votes

Error checking in our SimpleSubroutine project

 

In our SimpleSubroutine project we did not do any error checking. The Interpreter Object in Freedom script does support c# exceptions.  FS supports and will throw three exceptions when run or loaded.

  • Syntax error (in your FS script)
  • Internal error (error in structure or logic that could not be resolved)
  • Runtime error (something bad happened that would have crashed FS)

Freedom Script will populate the message property of the exception with as much information as it can to help handle the error. I recommend utilizing Try blocks to implement error handling. Below is a standard setup I use.

Interpreter interp = new Interpreter();
        try
        {
            interp.Load(new StreamReader("test.lang"));
            while (!interp.AtEndOfCode())
            {
                interp.Run(StepByStep.STEP_OVER);
//                Console.WriteLine("step at " + interp.LastExecutedLine());
            }
        }
        catch (SyntaxError e)
        {
            Console.WriteLine("Syntax Error:");
            Console.WriteLine(e.Message);
        }
        catch (InternalError e)
        {
            Console.WriteLine("Internal Error:");
            Console.WriteLine(e.Message);
        }
        catch (RuntimeError e)
        {
            Console.WriteLine("Runtime Error:");
            Console.WriteLine(e.Message);
        }

 

 

Bill R 

2016

Site Map | Printable View | © 2008 - 2020 GoodCarma.net | GoodCarma.net | Community Tools since 2008 | SmithTown New York