Difference between revisions of "Throw"

From Mesham
Jump to navigationJump to search
(Created page with '== Syntax == throw errorstring; == Semantics == Will throw the error string, and either cause termination of the program or, if caught by a try catch block, will be dealt with…')
 
Line 8: Line 8:
  
 
== Example ==
 
== Example ==
 
+
#include <io>
  try
+
  try {
{
 
 
     throw "an error"
 
     throw "an error"
 
  } catch "an error" {
 
  } catch "an error" {
     print["Error occurred!\n"];
+
     print("Error occurred!\n");
 
  };
 
  };
  

Revision as of 15:57, 12 January 2013

Syntax

throw errorstring;

Semantics

Will throw the error string, and either cause termination of the program or, if caught by a try catch block, will be dealt with.

Example

#include <io>
try {
   throw "an error"
} catch "an error" {
   print("Error occurred!\n");
};

In this example, a programmer defined error an error is thrown and caught.