Runtime exceptions

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
(Created page with "when a error is detected while executing a program, like a division by zero, access to a invalid memory location, etc, most languages provide a way define code to try to handl...")
 
Line 1: Line 1:
when a error is detected while executing a program, like a division by zero, access to a invalid memory location, etc, most languages provide a way define code to try to handle them.<br>
+
When a error is detected while executing a program, like a division by zero, access to a invalid memory location, etc, most languages provide a way define code to try to handle them.<br>
 
Default action is usually to issue a message and kill the program.
 
Default action is usually to issue a message and kill the program.
 +
.Net (the enviroment OpenSimulator runs on) creates a block of data (object) called Exception, with information about what happened and where.
 +
runtime control code abort current execution  and looks if the code path been executed is inside a try {} block. If there are catch {} blocks after if, the runtime  those are called with that Exception as argument, so code can try to handle it, preventing the program to just stop.
 +
There can be derivatives types of Exception, to make more clean the problem, and include more detailed information.
 +
Using this mechanism, programs can also create their own types and issue (throw) them when there is a need to abort execution, and go back to a relevant catch{} block.
 +
This is for example how llResetScript stops the script execution and goes back to control.
 +
 +
On YEngine lower case in used for exception names, and only knows 2 types, for now.
 +
* exception ( ie .net Exception) means any kind of Exception a script can be allowed to intercept.
 +
* scriptexception (.net ScriptException) a exception issued by the scripts supporting code.
 +
 +
most relevant cases for scripts will be type scriptexception.

Revision as of 05:02, 21 September 2020

When a error is detected while executing a program, like a division by zero, access to a invalid memory location, etc, most languages provide a way define code to try to handle them.
Default action is usually to issue a message and kill the program. .Net (the enviroment OpenSimulator runs on) creates a block of data (object) called Exception, with information about what happened and where. runtime control code abort current execution and looks if the code path been executed is inside a try {} block. If there are catch {} blocks after if, the runtime those are called with that Exception as argument, so code can try to handle it, preventing the program to just stop. There can be derivatives types of Exception, to make more clean the problem, and include more detailed information. Using this mechanism, programs can also create their own types and issue (throw) them when there is a need to abort execution, and go back to a relevant catch{} block. This is for example how llResetScript stops the script execution and goes back to control.

On YEngine lower case in used for exception names, and only knows 2 types, for now.

  • exception ( ie .net Exception) means any kind of Exception a script can be allowed to intercept.
  • scriptexception (.net ScriptException) a exception issued by the scripts supporting code.

most relevant cases for scripts will be type scriptexception.

Personal tools
General
About This Wiki