mb_set_error

Previous  Next

 

status_t mb_set_error( mb_interpreter_t* s, void** l, mb_error_e err )

 


 

Sets an error condition with the error code err. The error code is one of the mb_error_e error codes listed in MyBASIC2.h or any of the custom codes added using mb_add_error.  This will cause any defined error handlers to be called or if the user has set an error handler using ON ERROR then this will be called.

 

After setting the error code, your function should return MB_FUNC_ERR to raise the error condition and start the MyBASIC2 standard error handline.

 

Example

 

/////////////////////////////////////////////////////////////////////////////

//

int mb_pl_getprecision( mb_interpreter_t* s, void** l )

  {

  AFX_MANAGE_STATE( AfxGetStaticModuleState() );

  //////////////////////////////////////////////////////////////////////////

 

  mb_check( mb_attempt_open_bracket( s, l ) );

  mb_check( mb_attempt_close_bracket( s, l ) );

 

  if ( !theApp.GetPropList() )

     {

     mb_set_error( s, l, SE_RN_MODULE_NOT_LOADED );

    

     return MB_FUNC_ERR;

     }

  endif

 

  mb_check( mb_push_int( s, l, theApp.GetPropList()->GetPrecision() ) );

 

  return MB_FUNC_OK;

  }

endfunc