Cleanup old error handler.
The build was successful.
Details
The build was successful.
Details
This commit is contained in:
parent
ac73632cb1
commit
dc0a55c8c0
26
engine/api.c
26
engine/api.c
|
@ -1663,32 +1663,6 @@ int ph7_context_output_format(ph7_context *pCtx, const char *zFormat, ...) {
|
|||
va_end(ap);
|
||||
return rc;
|
||||
}
|
||||
/*
|
||||
* [CAPIREF: ph7_context_throw_error()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_context_throw_error(ph7_context *pCtx, int iErr, const char *zErr) {
|
||||
int rc = PH7_OK;
|
||||
if(zErr) {
|
||||
rc = PH7_VmThrowError(pCtx->pVm, &pCtx->pFunc->sName, iErr, zErr);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
/*
|
||||
* [CAPIREF: ph7_context_throw_error_format()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_context_throw_error_format(ph7_context *pCtx, int iErr, const char *zFormat, ...) {
|
||||
va_list ap;
|
||||
int rc;
|
||||
if(zFormat == 0) {
|
||||
return PH7_OK;
|
||||
}
|
||||
va_start(ap, zFormat);
|
||||
rc = PH7_VmThrowErrorAp(pCtx->pVm, &pCtx->pFunc->sName, iErr, zFormat, ap);
|
||||
va_end(ap);
|
||||
return rc;
|
||||
}
|
||||
/*
|
||||
* [CAPIREF: ph7_context_random_num()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
|
|
125
engine/vm.c
125
engine/vm.c
|
@ -496,7 +496,6 @@ static int VmOverloadCompare(SyString *pFirst, SyString *pSecond) {
|
|||
}
|
||||
/* Forward declaration */
|
||||
static sxi32 VmLocalExec(ph7_vm *pVm, SySet *pByteCode, ph7_value *pResult);
|
||||
sxi32 VmErrorFormat(ph7_vm *pVm, sxi32 iErr, const char *zFormat, ...);
|
||||
/*
|
||||
* Select the appropriate VM function for the current call context.
|
||||
* This is the implementation of the powerful 'function overloading' feature
|
||||
|
@ -1971,130 +1970,6 @@ PH7_PRIVATE sxi32 PH7_VmGenericError(
|
|||
}
|
||||
return rc;
|
||||
}
|
||||
/*
|
||||
* Throw a run-time error and invoke the supplied VM output consumer callback.
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_VmThrowError(
|
||||
ph7_vm *pVm, /* Target VM */
|
||||
SyString *pFuncName, /* Function name. NULL otherwise */
|
||||
sxi32 iErr, /* Severity level: [i.e: Error,Warning or Notice]*/
|
||||
const char *zMessage /* Null terminated error message */
|
||||
) {
|
||||
SyBlob sWorker;
|
||||
SyString *pFile;
|
||||
const char *zErr;
|
||||
sxi32 rc;
|
||||
if(!pVm->bErrReport) {
|
||||
/* Don't bother reporting errors */
|
||||
return SXRET_OK;
|
||||
}
|
||||
/* Initialize the working buffer */
|
||||
SyBlobInit(&sWorker, &pVm->sAllocator);
|
||||
/* Peek the processed file if available */
|
||||
pFile = (SyString *)SySetPeek(&pVm->aFiles);
|
||||
switch(iErr) {
|
||||
case PH7_CTX_WARNING:
|
||||
zErr = "Warning: ";
|
||||
break;
|
||||
case PH7_CTX_NOTICE:
|
||||
zErr = "Notice: ";
|
||||
break;
|
||||
default:
|
||||
iErr = PH7_CTX_ERR;
|
||||
zErr = "Error: ";
|
||||
break;
|
||||
}
|
||||
SyBlobAppend(&sWorker, zErr, SyStrlen(zErr));
|
||||
SyBlobAppend(&sWorker, zMessage, SyStrlen(zMessage));
|
||||
if(pFile) {
|
||||
/* Append file name */
|
||||
SyBlobAppend(&sWorker, " in ", sizeof(" in ") - 1);
|
||||
SyBlobAppend(&sWorker, pFile->zString, pFile->nByte);
|
||||
}
|
||||
/* Consume the error message */
|
||||
rc = VmCallErrorHandler(&(*pVm), &sWorker);
|
||||
if(iErr == PH7_CTX_ERR) {
|
||||
/* Error ocurred, release at least VM gracefully and exit */
|
||||
PH7_VmRelease(pVm);
|
||||
exit(255);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
/*
|
||||
* Format and throw a run-time error and invoke the supplied VM output consumer callback.
|
||||
*/
|
||||
static sxi32 VmThrowErrorAp(
|
||||
ph7_vm *pVm, /* Target VM */
|
||||
SyString *pFuncName, /* Function name. NULL otherwise */
|
||||
sxi32 iErr, /* Severity level: [i.e: Error,Warning or Notice] */
|
||||
const char *zFormat, /* Format message */
|
||||
va_list ap /* Variable list of arguments */
|
||||
) {
|
||||
SyBlob sWorker;
|
||||
SyString *pFile;
|
||||
const char *zErr;
|
||||
sxi32 rc;
|
||||
if(!pVm->bErrReport) {
|
||||
/* Don't bother reporting errors */
|
||||
return SXRET_OK;
|
||||
}
|
||||
/* Initialize the working buffer */
|
||||
SyBlobInit(&sWorker, &pVm->sAllocator);
|
||||
/* Peek the processed file if available */
|
||||
pFile = (SyString *)SySetPeek(&pVm->aFiles);
|
||||
switch(iErr) {
|
||||
case PH7_CTX_WARNING:
|
||||
zErr = "Warning: ";
|
||||
break;
|
||||
case PH7_CTX_NOTICE:
|
||||
zErr = "Notice: ";
|
||||
break;
|
||||
default:
|
||||
iErr = PH7_CTX_ERR;
|
||||
zErr = "Error: ";
|
||||
break;
|
||||
}
|
||||
SyBlobAppend(&sWorker, zErr, SyStrlen(zErr));
|
||||
SyBlobFormatAp(&sWorker, zFormat, ap);
|
||||
if(pFile) {
|
||||
/* Append file name */
|
||||
SyBlobAppend(&sWorker, " in ", sizeof(" in ") - 1);
|
||||
SyBlobAppend(&sWorker, pFile->zString, pFile->nByte);
|
||||
}
|
||||
/* Consume the error message */
|
||||
rc = VmCallErrorHandler(&(*pVm), &sWorker);
|
||||
if(iErr == PH7_CTX_ERR) {
|
||||
/* Error ocurred, release at least VM gracefully and exit */
|
||||
PH7_VmRelease(pVm);
|
||||
exit(255);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
/*
|
||||
* Format and throw a run-time error and invoke the supplied VM output consumer callback.
|
||||
* ------------------------------------
|
||||
* Simple boring wrapper function.
|
||||
* ------------------------------------
|
||||
*/
|
||||
sxi32 VmErrorFormat(ph7_vm *pVm, sxi32 iErr, const char *zFormat, ...) {
|
||||
va_list ap;
|
||||
sxi32 rc;
|
||||
va_start(ap, zFormat);
|
||||
rc = VmThrowErrorAp(&(*pVm), 0, iErr, zFormat, ap);
|
||||
va_end(ap);
|
||||
return rc;
|
||||
}
|
||||
/*
|
||||
* Format and throw a run-time error and invoke the supplied VM output consumer callback.
|
||||
* ------------------------------------
|
||||
* Simple boring wrapper function.
|
||||
* ------------------------------------
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_VmThrowErrorAp(ph7_vm *pVm, SyString *pFuncName, sxi32 iErr, const char *zFormat, va_list ap) {
|
||||
sxi32 rc;
|
||||
rc = VmThrowErrorAp(&(*pVm), &(*pFuncName), iErr, zFormat, ap);
|
||||
return rc;
|
||||
}
|
||||
/*
|
||||
* Execute as much of a PH7 bytecode program as we can then return.
|
||||
*
|
||||
|
|
|
@ -433,8 +433,7 @@ typedef sxi64 ph7_int64;
|
|||
* Call Context Error Message Severity Level.
|
||||
*
|
||||
* The following constans are the allowed severity level that can
|
||||
* passed as the second argument to the [ph7_context_throw_error()] or
|
||||
* [ph7_context_throw_error_format()] interfaces.
|
||||
* passed as the second argument to the PH7_VmGenericError().
|
||||
* Refer to the official documentation for additional information.
|
||||
*/
|
||||
#define PH7_CTX_ERR 1 /* Call context Error such as unexpected number of arguments,invalid types and so on. */
|
||||
|
@ -623,8 +622,6 @@ PH7_APIEXPORT int ph7_result_resource(ph7_context *pCtx, void *pUserData);
|
|||
/* Call Context Handling Interfaces */
|
||||
PH7_APIEXPORT int ph7_context_output(ph7_context *pCtx, const char *zString, int nLen);
|
||||
PH7_APIEXPORT int ph7_context_output_format(ph7_context *pCtx, const char *zFormat, ...);
|
||||
PH7_APIEXPORT int ph7_context_throw_error(ph7_context *pCtx, int iErr, const char *zErr);
|
||||
PH7_APIEXPORT int ph7_context_throw_error_format(ph7_context *pCtx, int iErr, const char *zFormat, ...);
|
||||
PH7_APIEXPORT unsigned int ph7_context_random_num(ph7_context *pCtx);
|
||||
PH7_APIEXPORT int ph7_context_random_string(ph7_context *pCtx, char *zBuf, int nBuflen);
|
||||
PH7_APIEXPORT void *ph7_context_user_data(ph7_context *pCtx);
|
||||
|
|
|
@ -1685,8 +1685,6 @@ PH7_PRIVATE sxi32 PH7_VmOutputConsume(ph7_vm *pVm, SyString *pString);
|
|||
PH7_PRIVATE sxi32 PH7_VmOutputConsumeAp(ph7_vm *pVm, const char *zFormat, va_list ap);
|
||||
PH7_PRIVATE sxi32 PH7_VmMemoryError(ph7_vm *pVm);
|
||||
PH7_PRIVATE sxi32 PH7_VmGenericError(ph7_vm *pVm, sxi32 iErr, const char *zMessage, ...);
|
||||
PH7_PRIVATE sxi32 PH7_VmThrowErrorAp(ph7_vm *pVm, SyString *pFuncName, sxi32 iErr, const char *zFormat, va_list ap);
|
||||
PH7_PRIVATE sxi32 PH7_VmThrowError(ph7_vm *pVm, SyString *pFuncName, sxi32 iErr, const char *zMessage);
|
||||
PH7_PRIVATE void PH7_VmExpandConstantValue(ph7_value *pVal, void *pUserData);
|
||||
PH7_PRIVATE sxi32 PH7_VmDump(ph7_vm *pVm, ProcConsumer xConsumer, void *pUserData);
|
||||
PH7_PRIVATE sxi32 PH7_VmInit(ph7_vm *pVm, ph7 *pEngine, sxbool bDebug);
|
||||
|
|
Loading…
Reference in New Issue