void hb_memvarGetRefer( PHB_ITEM pItem, PHB_SYMB pMemvarSymb ) { PHB_DYNS pDyn; HB_TRACE( HB_TR_DEBUG, ( "hb_memvarGetRefer(%p, %p)", pItem, pMemvarSymb ) ); pDyn = ( PHB_DYNS ) pMemvarSymb->pDynSym; if( pDyn ) { PHB_ITEM pMemvar; pMemvar = hb_dynsymGetMemvar( pDyn ); HB_TRACE( HB_TR_INFO, ( "Memvar item (%p)(%s) referenced", pMemvar, pMemvarSymb->szName ) ); if( pMemvar ) { if( HB_IS_BYREF( pMemvar ) && ! HB_IS_ENUM( pMemvar ) ) hb_itemCopy( pItem, pMemvar ); else { /* value is already created */ pItem->type = HB_IT_BYREF | HB_IT_MEMVAR; pItem->item.asMemvar.value = pMemvar; hb_xRefInc( pMemvar ); } } else { /* Generate an error with retry possibility * (user created error handler can make this variable accessible) */ PHB_ITEM pError; pError = hb_errRT_New( ES_ERROR, NULL, EG_NOVAR, 1003, NULL, pMemvarSymb->szName, 0, EF_CANRETRY ); while( hb_errLaunch( pError ) == E_RETRY ) { pMemvar = hb_dynsymGetMemvar( pDyn ); if( pMemvar ) { if( HB_IS_BYREF( pMemvar ) && ! HB_IS_ENUM( pMemvar ) ) hb_itemCopy( pItem, pMemvar ); else { /* value is already created */ pItem->type = HB_IT_BYREF | HB_IT_MEMVAR; pItem->item.asMemvar.value = pMemvar; hb_xRefInc( pMemvar ); } break; } } hb_errRelease( pError ); } } else hb_errInternal( HB_EI_MVBADSYMBOL, NULL, pMemvarSymb->szName, NULL ); }
/* * Assign a value to a field. */ HB_ERRCODE hb_rddPutFieldValue( PHB_ITEM pItem, PHB_SYMB pFieldSymbol ) { HB_ERRCODE errCode; HB_TRACE( HB_TR_DEBUG, ( "hb_rddPutFieldValue(%p, %p)", pItem, pFieldSymbol ) ); errCode = hb_rddFieldPut( pItem, pFieldSymbol ); if( errCode == HB_FAILURE && hb_vmRequestQuery() == 0 ) { /* * generate an error with retry possibility * (user created error handler can make this field accessible) */ PHB_ITEM pError = hb_errRT_New( ES_ERROR, NULL, EG_NOVAR, EDBCMD_NOVAR, NULL, pFieldSymbol->szName, 0, EF_CANRETRY ); while( hb_errLaunch( pError ) == E_RETRY ) { errCode = hb_rddFieldPut( pItem, pFieldSymbol ); if( errCode == HB_SUCCESS || hb_vmRequestQuery() != 0 ) break; } hb_itemRelease( pError ); } return errCode; }
static void s_pp_msg( void * cargo, int iErrorFmt, int iLine, const char * szModule, char cPrefix, int iValue, const char * szText, const char * szPar1, const char * szPar2 ) { HB_SYMBOL_UNUSED( cargo ); /* ignore all warning messages and errors when break or quit request */ if( cPrefix != 'W' && hb_vmRequestQuery() == 0 ) { char szMsgBuf[ 512 ], szLine[ 512 ]; PHB_ITEM pError; hb_snprintf( szMsgBuf, sizeof( szMsgBuf ), szText, szPar1, szPar2 ); if( ! szModule || *szModule == 0 || strcmp( szModule, "{SOURCE}.prg" ) == 0 ) hb_snprintf( szLine, sizeof( szLine ), "line:%i", iLine ); else hb_snprintf( szLine, sizeof( szLine ), iErrorFmt == HB_ERRORFMT_CLIPPER ? "%s(%i)" : "%s:%i", szModule, iLine ); pError = hb_errRT_New( ES_ERROR, "COMPILER", 1001, ( HB_ERRCODE ) iValue, szMsgBuf, szLine, 0 /*OsCode*/, EF_NONE ); hb_errLaunch( pError ); hb_errRelease( pError ); } }
HB_USHORT hb_errRT_BASE( HB_ERRCODE errGenCode, HB_ERRCODE errSubCode, const char * szDescription, const char * szOperation, HB_ULONG ulArgCount, ... ) { HB_USHORT uiAction; PHB_ITEM pError; PHB_ITEM pArray; va_list va; HB_ULONG ulArgPos; /* I replaced EF_CANRETRY with EF_NONE for Clipper compatibility * If it's wrong and I missed something please fix me, Druzus. */ pError = hb_errRT_New( ES_ERROR, HB_ERR_SS_BASE, errGenCode, errSubCode, szDescription, szOperation, 0, EF_NONE /* EF_CANRETRY */ ); /* Build the array from the passed arguments. */ switch( ulArgCount ) { case 0: pArray = NULL; break; case HB_ERR_ARGS_BASEPARAMS: pArray = hb_pcount() ? hb_arrayBaseParams() : NULL; break; case HB_ERR_ARGS_SELFPARAMS: pArray = hb_arraySelfParams(); break; default: pArray = hb_itemArrayNew( ulArgCount ); va_start( va, ulArgCount ); for( ulArgPos = 1; ulArgPos <= ulArgCount; ulArgPos++ ) { PHB_ITEM pArg = va_arg( va, PHB_ITEM ); if( pArg ) hb_itemArrayPut( pArray, ulArgPos, pArg ); } va_end( va ); } if( pArray ) { /* Assign the new array to the object data item. */ hb_errPutArgsArray( pError, pArray ); /* Release the Array. */ hb_itemRelease( pArray ); } /* Ok, launch... */ uiAction = hb_errLaunch( pError ); /* Release. */ hb_errRelease( pError ); return uiAction; }
/* ===================================================================================== */ static HB_USHORT hb_errRT_PostgreSQLDD( HB_ERRCODE errGenCode, HB_ERRCODE errSubCode, const char * szDescription, const char * szOperation, HB_ERRCODE errOsCode ) { HB_USHORT uiAction; PHB_ITEM pError; pError = hb_errRT_New( ES_ERROR, "SDDPG", errGenCode, errSubCode, szDescription, szOperation, errOsCode, EF_NONE ); uiAction = hb_errLaunch( pError ); hb_itemRelease( pError ); return uiAction; }
HB_USHORT hb_errRT_BASE_Ext1( HB_ERRCODE errGenCode, HB_ERRCODE errSubCode, const char * szDescription, const char * szOperation, HB_ERRCODE errOsCode, HB_USHORT uiFlags, HB_ULONG ulArgCount, ... ) { HB_USHORT uiAction; PHB_ITEM pError; PHB_ITEM pArray; va_list va; HB_ULONG ulArgPos; pError = hb_errRT_New( ES_ERROR, HB_ERR_SS_BASE, errGenCode, errSubCode, szDescription, szOperation, errOsCode, uiFlags ); /* Build the array from the passed arguments. */ switch( ulArgCount ) { case 0: pArray = NULL; break; case HB_ERR_ARGS_BASEPARAMS: pArray = hb_pcount() ? hb_arrayBaseParams() : NULL; break; case HB_ERR_ARGS_SELFPARAMS: pArray = hb_arraySelfParams(); break; default: pArray = hb_itemArrayNew( ulArgCount ); va_start( va, ulArgCount ); for( ulArgPos = 1; ulArgPos <= ulArgCount; ulArgPos++ ) { PHB_ITEM pArg = va_arg( va, PHB_ITEM ); if( pArg ) hb_itemArrayPut( pArray, ulArgPos, pArg ); } va_end( va ); } if( pArray ) { /* Assign the new array to the object data item. */ hb_errPutArgsArray( pError, pArray ); /* Release the Array. */ hb_itemRelease( pArray ); } /* Ok, launch... */ uiAction = hb_errLaunch( pError ); hb_errRelease( pError ); return uiAction; }
HB_USHORT hb_errRT_DBCMD( HB_ERRCODE errGenCode, HB_ERRCODE errSubCode, const char * szDescription, const char * szOperation ) { HB_USHORT uiAction; PHB_ITEM pError = hb_errRT_New( ES_ERROR, HB_ERR_SS_DBCMD, errGenCode, errSubCode, szDescription, szOperation, 0, EF_NONE ); uiAction = hb_errLaunch( pError ); hb_errRelease( pError ); return uiAction; }
HB_USHORT hb_errRT_TERM( HB_ERRCODE errGenCode, HB_ERRCODE errSubCode, const char * szDescription, const char * szOperation, HB_ERRCODE errOsCode, HB_USHORT uiFlags ) { HB_USHORT uiAction; PHB_ITEM pError = hb_errRT_New( ES_ERROR, HB_ERR_SS_TERMINAL, errGenCode, errSubCode, szDescription, szOperation, errOsCode, uiFlags ); uiAction = hb_errLaunch( pError ); hb_errRelease( pError ); return uiAction; }
static HB_ERRCODE hb_errRT_SQLBASE( HB_ERRCODE errGenCode, HB_ERRCODE errSubCode, const char * szDescription, const char * szOperation ) { PHB_ITEM pError; HB_ERRCODE iRet = HB_FAILURE; if( hb_vmRequestQuery() == 0 ) { pError = hb_errRT_New( ES_ERROR, "SQLBASE", errGenCode, errSubCode, szDescription, szOperation, 0, EF_NONE ); iRet = hb_errLaunch( pError ); hb_itemRelease( pError ); } return iRet; }
static void hb_errRT_OLE( HB_ERRCODE errGenCode, HB_ERRCODE errSubCode, HB_ERRCODE errOsCode, const char * szDescription, const char * szOperation ) { PHB_ITEM pError; pError = hb_errRT_New( ES_ERROR, "WINOLE", errGenCode, errSubCode, szDescription, szOperation, errOsCode, EF_NONE ); if( hb_pcount() != 0 ) { /* HB_ERR_ARGS_BASEPARAMS */ PHB_ITEM pArray = hb_arrayBaseParams(); hb_errPutArgsArray( pError, pArray ); hb_itemRelease( pArray ); } hb_errLaunch( pError ); hb_errRelease( pError ); }
static void s_errRT_IOUSR( HB_ERRCODE errGenCode, HB_ERRCODE errSubCode, const char * szDescription ) { PHB_ITEM pError, pArray; pError = hb_errRT_New( ES_ERROR, "IOUSR", errGenCode, errSubCode, szDescription, HB_ERR_FUNCNAME, 0, EF_NONE ); pArray = hb_arrayBaseParams(); if( pArray ) { hb_errPutArgsArray( pError, pArray ); hb_itemRelease( pArray ); } hb_errLaunch( pError ); hb_itemRelease( pError ); }
/* * Select a WorkArea by the name. */ HB_ERRCODE hb_rddSelectWorkAreaAlias( const char * szAlias ) { HB_ERRCODE errCode; int iArea; HB_TRACE( HB_TR_DEBUG, ( "hb_rddSelectWorkAreaAlias(%s)", szAlias ) ); errCode = hb_rddGetAliasNumber( szAlias, &iArea ); if( errCode == HB_FAILURE ) { /* * generate an error with retry possibility * (user created error handler can open a missing database) */ PHB_ITEM pError = hb_errRT_New( ES_ERROR, NULL, EG_NOALIAS, EDBCMD_NOALIAS, NULL, szAlias, 0, EF_CANRETRY ); do { if( hb_errLaunch( pError ) != E_RETRY ) break; errCode = hb_rddGetAliasNumber( szAlias, &iArea ); } while( errCode == HB_FAILURE ); hb_itemRelease( pError ); } if( errCode == HB_SUCCESS ) { if( iArea < 1 || iArea > HB_RDD_MAX_AREA_NUM ) errCode = hb_rddSelectFirstAvailable(); else errCode = hb_rddSelectWorkAreaNumber( iArea ); } return errCode; }
HB_EXTERN_BEGIN static void hb_pp_ErrorMessage( void * cargo, const char * const szMsgTable[], char cPrefix, int iCode, const char * szParam1, const char * szParam2 ) { HB_TRACE( HB_TR_DEBUG, ( "hb_pp_ErrorGen(%p, %p, %c, %d, %s, %s)", cargo, szMsgTable, cPrefix, iCode, szParam1, szParam2 ) ); HB_SYMBOL_UNUSED( cargo ); /* ignore all warning messages and errors when break or quit request */ if( cPrefix != 'W' && hb_vmRequestQuery() == 0 ) { char szMsgBuf[ 1024 ]; PHB_ITEM pError; hb_snprintf( szMsgBuf, sizeof( szMsgBuf ), szMsgTable[ iCode - 1 ], szParam1, szParam2 ); pError = hb_errRT_New( ES_ERROR, "PP", 1001, ( HB_ERRCODE ) iCode, szMsgBuf, NULL, 0, EF_NONE | EF_CANDEFAULT ); hb_errLaunch( pError ); hb_errRelease( pError ); } }
void hb_memvarGetValue( PHB_ITEM pItem, PHB_SYMB pMemvarSymb ) { HB_TRACE( HB_TR_DEBUG, ( "hb_memvarGetValue(%p, %p)", pItem, pMemvarSymb ) ); if( hb_memvarGet( pItem, pMemvarSymb ) == HB_FAILURE ) { /* Generate an error with retry possibility * (user created error handler can create this variable) */ PHB_ITEM pError; pError = hb_errRT_New( ES_ERROR, NULL, EG_NOVAR, 1003, NULL, pMemvarSymb->szName, 0, EF_CANRETRY ); while( hb_errLaunch( pError ) == E_RETRY ) { if( hb_memvarGet( pItem, pMemvarSymb ) == HB_SUCCESS ) break; } hb_errRelease( pError ); } }
/* * Select a WorkArea by the symbol name. */ HB_ERRCODE hb_rddSelectWorkAreaSymbol( PHB_SYMB pSymAlias ) { PHB_ITEM pError; HB_ERRCODE errCode; const char * szName; int iArea; HB_TRACE( HB_TR_DEBUG, ( "hb_rddSelectWorkAreaSymbol(%p)", pSymAlias ) ); iArea = ( int ) hb_dynsymAreaHandle( pSymAlias->pDynSym ); if( iArea ) { hb_rddSelectWorkAreaNumber( iArea ); return HB_SUCCESS; } szName = hb_dynsymName( pSymAlias->pDynSym ); if( szName[ 0 ] && ! szName[ 1 ] ) { if( szName[ 0 ] >= 'A' && szName[ 0 ] <= 'K' ) { hb_rddSelectWorkAreaNumber( szName[ 0 ] - 'A' + 1 ); return HB_SUCCESS; } else if( szName[ 0 ] >= 'a' && szName[ 0 ] <= 'k' ) { hb_rddSelectWorkAreaNumber( szName[ 0 ] - 'a' + 1 ); return HB_SUCCESS; } else if( szName[ 0 ] == 'M' || szName[ 0 ] == 'm' ) { hb_rddSelectWorkAreaNumber( HB_RDD_MAX_AREA_NUM ); return HB_SUCCESS; } } /* * generate an error with retry possibility * (user created error handler can open a missing database) */ pError = hb_errRT_New( ES_ERROR, NULL, EG_NOALIAS, EDBCMD_NOALIAS, NULL, pSymAlias->szName, 0, EF_CANRETRY ); errCode = HB_FAILURE; do { if( hb_errLaunch( pError ) != E_RETRY ) break; iArea = ( int ) hb_dynsymAreaHandle( pSymAlias->pDynSym ); if( iArea ) { hb_rddSelectWorkAreaNumber( iArea ); errCode = HB_SUCCESS; } } while( errCode == HB_FAILURE ); hb_itemRelease( pError ); return errCode; }
/* throwing a CT-subsystem error without value substitution - function adapted from errorapi.c */ HB_USHORT ct_error( HB_USHORT uiSeverity, HB_ERRCODE errGenCode, HB_ERRCODE errSubCode, const char * szDescription, const char * szOperation, HB_ERRCODE errOsCode, HB_USHORT uiFlags, HB_ULONG ulArgCount, ... ) { HB_USHORT uiAction; PHB_ITEM pError; PHB_ITEM pArray; va_list va; HB_ULONG ulArgPos; HB_TRACE( HB_TR_DEBUG, ( "ct_error(%hu, %d, %d, %s, %s, %d, %hu, %lu)", uiSeverity, errGenCode, errSubCode, szDescription, szOperation, errOsCode, uiFlags, ulArgCount ) ); pError = hb_errRT_New( uiSeverity, CT_SUBSYSTEM, errGenCode, errSubCode, szDescription, szOperation, errOsCode, uiFlags ); /* Build the array from the passed arguments. */ if( ulArgCount == 0 ) { pArray = NULL; } else if( ulArgCount == HB_ERR_ARGS_BASEPARAMS ) { if( hb_pcount() == 0 ) pArray = NULL; else pArray = hb_arrayBaseParams(); } else if( ulArgCount == HB_ERR_ARGS_SELFPARAMS ) { pArray = hb_arraySelfParams(); } else { pArray = hb_itemArrayNew( ulArgCount ); va_start( va, ulArgCount ); for( ulArgPos = 1; ulArgPos <= ulArgCount; ulArgPos++ ) { hb_itemArrayPut( pArray, ulArgPos, va_arg( va, PHB_ITEM ) ); } va_end( va ); } if( pArray ) { /* Assign the new array to the object data item. */ hb_vmPushSymbol( hb_dynsymGetSymbol( "_ARGS" ) ); hb_vmPush( pError ); hb_vmPush( pArray ); hb_vmSend( 1 ); /* Release the Array. */ hb_itemRelease( pArray ); } /* launch error codeblock */ uiAction = hb_errLaunch( pError ); /* release error codeblock */ hb_errRelease( pError ); return uiAction; }