TScript Error Handling
Error handling in many other languages is done through the use of exceptions. TScript uses a similar process of error handling, although slightly different. TScript has a global error variable similar to the traditional errno in C, although the error variable in TScript is capable to holding both an error code and a detailed error message.
In many languages that use the try{...}catch(...){...} the error is returned via the catch statement and this can make the operational flow of the code awkward in situations where some errors are recoverable. TScript uses the if(...){...} else{...} notation that allows calling code to filter the error, potentially recovering from the error and returning to normal operation, or returning the error to the its own calling function.
- TScript
function(){ return error = -1; } public main(){ if(!function(]){ if(error != -1) return error; } System::MessageBox(L"function executed correctly"); }