The throw statement can be used to throw an exception inside a function:

func doSomethingDangerous throws MyException:
	throw new MyException("This is an error")

This could be caught in calling code eg. like this:

try {
	doSomethingDangerous()
}
catch exception as MyException {
	PRINT exception.getErrorMessage()
}

Twitter Facebook LinkedIn Youtube Slideshare Github