val_throw() and val_rethrow()
The throw and rethrow functions are great for handling errors in code that you feel should be handled
by the Neko script calling the C/C++ library. Both functions are very similar, accepting a value struct as
its solitary parameter to be used as the exception object. The difference being, though, that while throw
deals with the creation of an exception, rethrow will forward an existing exception that otherwise
would have been handled.
val_throw( alloc_string( ???An unknown error occurred??? ) );
Exceptions thrown by the C/C++ layer should be handled in your Neko scripts. For more information
on exceptions, see Chapter 7 , ??? When Things Go Wrong. ???
failure()
The failure function is very useful when creating your own libraries, as it allows you to pass a string
constant for display in the command prompt, while raising a Neko error. This is great when you quickly
want to debug something without having to resort to large amounts of code in haXe, or if the error found
in the C/C++ code is something that should not be recovered from.
Pages:
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069