Advertisement
snake5

SGScript - error handling

Jul 22nd, 2013
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. include "string";
  2.  
  3.  
  4. function handler( type, msg )
  5. {
  6.     if( string_find( msg, "not found" ) )
  7.         sys_print( SGS_WARNING, "fuck this." );
  8. }
  9.  
  10. function handler2( type, msg )
  11. {
  12.     if( string_find( msg, "not found" ) )
  13.         return SGS_ERROR;
  14. }
  15.  
  16. pcall(function()
  17. {
  18.     print x; // nothing
  19. });
  20.  
  21. pcall(function()
  22. {
  23.     print x; // renamed warning
  24. },
  25. handler );
  26.  
  27. pcall(function()
  28. {
  29.     print x; // changed type to error
  30. },
  31. handler2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement