Browse Source

Rename PH7_VmGenericError() to PH7_VmThrowError()

Rafal Kupiec 7 months ago
parent
commit
d793d3ed70
Signed by: belliash <belliash@codingworkshop.eu.org> GPG Key ID: 4E829243E0CFE6B4
9 changed files with 252 additions and 252 deletions
  1. 1
    1
      engine/builtin.c
  2. 6
    6
      engine/hashmap.c
  3. 5
    5
      engine/oop.c
  4. 168
    168
      engine/vfs.c
  5. 67
    67
      engine/vm.c
  6. 1
    1
      include/ph7.h
  7. 1
    1
      include/ph7int.h
  8. 1
    1
      modules/json/json.c
  9. 2
    2
      modules/xml/xml.c

+ 1
- 1
engine/builtin.c View File

@@ -7240,7 +7240,7 @@ static int PH7_builtin_idate(ph7_context *pCtx, int nArg, ph7_value **apArg) {
7240 7240
 			break;
7241 7241
 		default:
7242 7242
 			/* unknown format,throw a warning */
7243
-			PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Unknown date format token");
7243
+			PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Unknown date format token");
7244 7244
 			break;
7245 7245
 	}
7246 7246
 	/* Return the time value */

+ 6
- 6
engine/hashmap.c View File

@@ -554,7 +554,7 @@ static sxi32 HashmapInsert(
554 554
 		}
555 555
 		if(pMap == pMap->pVm->pGlobal) {
556 556
 			/* Forbidden */
557
-			PH7_VmGenericError(pMap->pVm, PH7_CTX_NOTICE, "$GLOBALS is a read-only array, insertion is forbidden");
557
+			PH7_VmThrowError(pMap->pVm, PH7_CTX_NOTICE, "$GLOBALS is a read-only array, insertion is forbidden");
558 558
 			return SXRET_OK;
559 559
 		}
560 560
 		/* Perform a blob-key insertion */
@@ -583,7 +583,7 @@ IntKey:
583 583
 		}
584 584
 		if(pMap == pMap->pVm->pGlobal) {
585 585
 			/* Forbidden */
586
-			PH7_VmGenericError(pMap->pVm, PH7_CTX_NOTICE, "$GLOBALS is a read-only array, insertion is forbidden");
586
+			PH7_VmThrowError(pMap->pVm, PH7_CTX_NOTICE, "$GLOBALS is a read-only array, insertion is forbidden");
587 587
 			return SXRET_OK;
588 588
 		}
589 589
 		/* Perform a 64-bit-int-key insertion */
@@ -601,7 +601,7 @@ IntKey:
601 601
 	} else {
602 602
 		if(pMap == pMap->pVm->pGlobal) {
603 603
 			/* Forbidden */
604
-			PH7_VmGenericError(pMap->pVm, PH7_CTX_NOTICE, "$GLOBALS is a read-only array, insertion is forbidden");
604
+			PH7_VmThrowError(pMap->pVm, PH7_CTX_NOTICE, "$GLOBALS is a read-only array, insertion is forbidden");
605 605
 			return SXRET_OK;
606 606
 		}
607 607
 		/* Assign an automatic index */
@@ -1374,7 +1374,7 @@ PH7_PRIVATE sxi32 PH7_HashmapRelease(ph7_hashmap *pMap, int FreeDS) {
1374 1374
 	sxu32 n;
1375 1375
 	if(pMap == pVm->pGlobal) {
1376 1376
 		/* Cannot delete the $GLOBALS array */
1377
-		PH7_VmGenericError(pMap->pVm, PH7_CTX_NOTICE, "$GLOBALS is a read-only array, deletion is forbidden");
1377
+		PH7_VmThrowError(pMap->pVm, PH7_CTX_NOTICE, "$GLOBALS is a read-only array, deletion is forbidden");
1378 1378
 		return SXRET_OK;
1379 1379
 	}
1380 1380
 	/* Start the release process */
@@ -1464,7 +1464,7 @@ PH7_PRIVATE sxi32 PH7_HashmapInsert(
1464 1464
 		/*
1465 1465
 		 * TICKET 1433-35: Insertion in the $GLOBALS array is forbidden.
1466 1466
 		 */
1467
-		PH7_VmGenericError(pMap->pVm, PH7_CTX_ERR, "$GLOBALS is a read-only array, insertion is forbidden");
1467
+		PH7_VmThrowError(pMap->pVm, PH7_CTX_ERR, "$GLOBALS is a read-only array, insertion is forbidden");
1468 1468
 		return SXRET_OK;
1469 1469
 	}
1470 1470
 	rc = HashmapInsert(&(*pMap), &(*pKey), &(*pVal));
@@ -1507,7 +1507,7 @@ PH7_PRIVATE sxi32 PH7_HashmapInsertByRef(
1507 1507
 		/*
1508 1508
 		 * TICKET 1433-35: Insertion in the $GLOBALS array is forbidden.
1509 1509
 		 */
1510
-		PH7_VmGenericError(pMap->pVm, PH7_CTX_ERR, "$GLOBALS is a read-only array, insertion is forbidden");
1510
+		PH7_VmThrowError(pMap->pVm, PH7_CTX_ERR, "$GLOBALS is a read-only array, insertion is forbidden");
1511 1511
 		return SXRET_OK;
1512 1512
 	}
1513 1513
 	rc = HashmapInsertByRef(&(*pMap), &(*pKey), nRefIdx);

+ 5
- 5
engine/oop.c View File

@@ -263,7 +263,7 @@ PH7_PRIVATE sxi32 PH7_ClassInherit(ph7_vm *pVm, ph7_class *pSub, ph7_class *pBas
263 263
 		if((pEntry = SyHashGet(&pSub->hAttr, (const void *)pName->zString, pName->nByte)) != 0) {
264 264
 			if(pAttr->iProtection == PH7_CLASS_PROT_PRIVATE && ((ph7_class_attr *)pEntry->pUserData)->iProtection != PH7_CLASS_PROT_PUBLIC) {
265 265
 				/* Cannot redeclare private attribute */
266
-				rc = PH7_VmGenericError(pVm, PH7_CTX_ERR, "Private attribute '%z::%z' redeclared inside child class '%z'", &pBase->sName, pName, &pSub->sName);
266
+				rc = PH7_VmThrowError(pVm, PH7_CTX_ERR, "Private attribute '%z::%z' redeclared inside child class '%z'", &pBase->sName, pName, &pSub->sName);
267 267
 				if(rc == SXERR_ABORT) {
268 268
 					return SXERR_ABORT;
269 269
 				}
@@ -286,7 +286,7 @@ PH7_PRIVATE sxi32 PH7_ClassInherit(ph7_vm *pVm, ph7_class *pSub, ph7_class *pBas
286 286
 		if((pEntry = SyHashGet(&pSub->hMethod, (const void *)pName->zString, pName->nByte)) != 0) {
287 287
 			if(pMeth->iFlags & PH7_CLASS_ATTR_FINAL) {
288 288
 				/* Cannot Overwrite final method */
289
-				rc = PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Cannot overwrite final method '%z:%z()' inside child class '%z'", &pBase->sName, pName, &pSub->sName);
289
+				rc = PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Cannot overwrite final method '%z:%z()' inside child class '%z'", &pBase->sName, pName, &pSub->sName);
290 290
 				if(rc == SXERR_ABORT) {
291 291
 					return SXERR_ABORT;
292 292
 				}
@@ -295,7 +295,7 @@ PH7_PRIVATE sxi32 PH7_ClassInherit(ph7_vm *pVm, ph7_class *pSub, ph7_class *pBas
295 295
 		} else {
296 296
 			if(pMeth->iFlags & PH7_CLASS_ATTR_VIRTUAL) {
297 297
 				/* Virtual method must be defined in the child class */
298
-				rc = PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Virtual method '%z:%z()' must be defined inside child class '%z'", &pBase->sName, pName, &pSub->sName);
298
+				rc = PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Virtual method '%z:%z()' must be defined inside child class '%z'", &pBase->sName, pName, &pSub->sName);
299 299
 				if(rc == SXERR_ABORT) {
300 300
 					return SXERR_ABORT;
301 301
 				}
@@ -663,7 +663,7 @@ PH7_PRIVATE ph7_class_instance *PH7_CloneClassInstance(ph7_class_instance *pSrc)
663 663
 			PH7_VmCallClassMethod(pVm, pClone, pMethod, 0, 0, 0);
664 664
 		} else {
665 665
 			/* Nesting limit reached */
666
-			PH7_VmGenericError(pVm, PH7_CTX_ERR, "Object clone limit reached");
666
+			PH7_VmThrowError(pVm, PH7_CTX_ERR, "Object clone limit reached");
667 667
 		}
668 668
 		/* Reset the cursor */
669 669
 		pMethod->iCloneDepth = 0;
@@ -807,7 +807,7 @@ PH7_PRIVATE sxi32 PH7_ClassInstanceCmp(ph7_class_instance *pLeft, ph7_class_inst
807 807
 	sxi32 rc;
808 808
 	if(iNest > 31) {
809 809
 		/* Nesting limit reached */
810
-		PH7_VmGenericError(pLeft->pVm, PH7_CTX_ERR, "Nesting limit reached, probably infinite recursion");
810
+		PH7_VmThrowError(pLeft->pVm, PH7_CTX_ERR, "Nesting limit reached, probably infinite recursion");
811 811
 		return 1;
812 812
 	}
813 813
 	/* Comparison is performed only if the objects are instance of the same class */

+ 168
- 168
engine/vfs.c
File diff suppressed because it is too large
View File


+ 67
- 67
engine/vm.c View File

@@ -287,7 +287,7 @@ PH7_PRIVATE sxi32 PH7_VmInstallClass(
287 287
 	/* Check for duplicates */
288 288
 	pEntry = SyHashGet(&pVm->hClass, (const void *)pName->zString, pName->nByte);
289 289
 	if(pEntry) {
290
-		PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Cannot declare class, because the name is already in use");
290
+		PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Cannot declare class, because the name is already in use");
291 291
 	}
292 292
 	/* Perform a simple hashtable insertion */
293 293
 	rc = SyHashInsert(&pVm->hClass, (const void *)pName->zString, pName->nByte, pClass);
@@ -540,7 +540,7 @@ static ph7_vm_func *VmOverload(
540 540
 	}
541 541
 	if(i < 1) {
542 542
 		/* No candidates, throw an error */
543
-		PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Invalid number of arguments passed to function/method '%z()'", &pList->sName);
543
+		PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Invalid number of arguments passed to function/method '%z()'", &pList->sName);
544 544
 	}
545 545
 	if(nArg < 1 || i < 2) {
546 546
 		/* Return the only candidate */
@@ -1889,7 +1889,7 @@ PH7_PRIVATE sxi32 PH7_VmMemoryError(
1889 1889
 /*
1890 1890
  * Throw a run-time error and invoke the supplied VM output consumer callback.
1891 1891
  */
1892
-PH7_PRIVATE sxi32 PH7_VmGenericError(
1892
+PH7_PRIVATE sxi32 PH7_VmThrowError(
1893 1893
 	ph7_vm *pVm,          /* Target VM */
1894 1894
 	sxi32 iErr,           /* Severity level: [i.e: Error, Warning, Notice or Deprecated] */
1895 1895
 	const char *zMessage, /* Null terminated error message */
@@ -2546,7 +2546,7 @@ static sxi32 VmByteCodeExec(
2546 2546
 								pTos->nIdx = SXU32_HIGH;
2547 2547
 							}
2548 2548
 							/* Emit a notice */
2549
-							PH7_VmGenericError(&(*pVm), PH7_CTX_NOTICE,
2549
+							PH7_VmThrowError(&(*pVm), PH7_CTX_NOTICE,
2550 2550
 											 "Attempt to access an undefined array index, PH7 is loading NULL");
2551 2551
 							break;
2552 2552
 						}
@@ -2678,7 +2678,7 @@ static sxi32 VmByteCodeExec(
2678 2678
 							PH7_MemObjInit(pVm, &sEnv.sValue);
2679 2679
 							if(sEnv.iFlags & VM_FUNC_ARG_BY_REF) {
2680 2680
 								/* Pass by reference */
2681
-								PH7_VmGenericError(pVm, PH7_CTX_WARNING,
2681
+								PH7_VmThrowError(pVm, PH7_CTX_WARNING,
2682 2682
 												 "Pass by reference is disabled in the current release of the PH7 engine, PH7 is switching to pass by value");
2683 2683
 							}
2684 2684
 							/* Standard pass by value */
@@ -2715,7 +2715,7 @@ static sxi32 VmByteCodeExec(
2715 2715
 						nIdx = pTos->nIdx;
2716 2716
 						VmPopOperand(&pTos, 1);
2717 2717
 						if(nIdx == SXU32_HIGH) {
2718
-							PH7_VmGenericError(&(*pVm), PH7_CTX_WARNING,
2718
+							PH7_VmThrowError(&(*pVm), PH7_CTX_WARNING,
2719 2719
 											 "Cannot perform assignment on a constant class attribute, PH7 is loading NULL");
2720 2720
 							pTos->nIdx = SXU32_HIGH;
2721 2721
 						} else {
@@ -3071,7 +3071,7 @@ static sxi32 VmByteCodeExec(
3071 3071
 					if(pInstr->iOp == PH7_OP_MUL_STORE) {
3072 3072
 						ph7_value *pObj;
3073 3073
 						if(pTos->nIdx == SXU32_HIGH) {
3074
-							PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Cannot perform assignment on a constant class attribute");
3074
+							PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Cannot perform assignment on a constant class attribute");
3075 3075
 						} else if((pObj = (ph7_value *)SySetAt(&pVm->aMemObj, pTos->nIdx)) != 0) {
3076 3076
 							PH7_MemObjStore(pNos, pObj);
3077 3077
 						}
@@ -3151,7 +3151,7 @@ static sxi32 VmByteCodeExec(
3151 3151
 					}
3152 3152
 					/* Perform the store operation */
3153 3153
 					if(pTos->nIdx == SXU32_HIGH) {
3154
-						PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Cannot perform assignment on a constant class attribute");
3154
+						PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Cannot perform assignment on a constant class attribute");
3155 3155
 					} else if((pObj = (ph7_value *)SySetAt(&pVm->aMemObj, pTos->nIdx)) != 0) {
3156 3156
 						PH7_MemObjStore(pTos, pObj);
3157 3157
 					}
@@ -3245,7 +3245,7 @@ static sxi32 VmByteCodeExec(
3245 3245
 						MemObjSetType(pNos, MEMOBJ_INT);
3246 3246
 					}
3247 3247
 					if(pTos->nIdx == SXU32_HIGH) {
3248
-						PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Cannot perform assignment on a constant class attribute");
3248
+						PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Cannot perform assignment on a constant class attribute");
3249 3249
 					} else if((pObj = (ph7_value *)SySetAt(&pVm->aMemObj, pTos->nIdx)) != 0) {
3250 3250
 						PH7_MemObjStore(pNos, pObj);
3251 3251
 					}
@@ -3281,7 +3281,7 @@ static sxi32 VmByteCodeExec(
3281 3281
 					b = pTos->x.iVal;
3282 3282
 					if(b == 0) {
3283 3283
 						r = 0;
3284
-						PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Division by zero %qd%%0", a);
3284
+						PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Division by zero %qd%%0", a);
3285 3285
 						/* goto Abort; */
3286 3286
 					} else {
3287 3287
 						r = a % b;
@@ -3322,7 +3322,7 @@ static sxi32 VmByteCodeExec(
3322 3322
 					b = pNos->x.iVal;
3323 3323
 					if(b == 0) {
3324 3324
 						r = 0;
3325
-						PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Division by zero %qd%%0", a);
3325
+						PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Division by zero %qd%%0", a);
3326 3326
 						/* goto Abort; */
3327 3327
 					} else {
3328 3328
 						r = a % b;
@@ -3331,7 +3331,7 @@ static sxi32 VmByteCodeExec(
3331 3331
 					pNos->x.iVal = r;
3332 3332
 					MemObjSetType(pNos, MEMOBJ_INT);
3333 3333
 					if(pTos->nIdx == SXU32_HIGH) {
3334
-						PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Cannot perform assignment on a constant class attribute");
3334
+						PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Cannot perform assignment on a constant class attribute");
3335 3335
 					} else if((pObj = (ph7_value *)SySetAt(&pVm->aMemObj, pTos->nIdx)) != 0) {
3336 3336
 						PH7_MemObjStore(pNos, pObj);
3337 3337
 					}
@@ -3367,7 +3367,7 @@ static sxi32 VmByteCodeExec(
3367 3367
 					if(b == 0) {
3368 3368
 						/* Division by zero */
3369 3369
 						r = 0;
3370
-						PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Division by zero");
3370
+						PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Division by zero");
3371 3371
 						/* goto Abort; */
3372 3372
 					} else {
3373 3373
 						r = a / b;
@@ -3410,7 +3410,7 @@ static sxi32 VmByteCodeExec(
3410 3410
 					if(b == 0) {
3411 3411
 						/* Division by zero */
3412 3412
 						r = 0;
3413
-						PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Division by zero %qd/0", a);
3413
+						PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Division by zero %qd/0", a);
3414 3414
 						/* goto Abort; */
3415 3415
 					} else {
3416 3416
 						r = a / b;
@@ -3421,7 +3421,7 @@ static sxi32 VmByteCodeExec(
3421 3421
 						PH7_MemObjTryInteger(pNos);
3422 3422
 					}
3423 3423
 					if(pTos->nIdx == SXU32_HIGH) {
3424
-						PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Cannot perform assignment on a constant class attribute");
3424
+						PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Cannot perform assignment on a constant class attribute");
3425 3425
 					} else if((pObj = (ph7_value *)SySetAt(&pVm->aMemObj, pTos->nIdx)) != 0) {
3426 3426
 						PH7_MemObjStore(pNos, pObj);
3427 3427
 					}
@@ -3545,7 +3545,7 @@ static sxi32 VmByteCodeExec(
3545 3545
 					pNos->x.iVal = r;
3546 3546
 					MemObjSetType(pNos, MEMOBJ_INT);
3547 3547
 					if(pTos->nIdx == SXU32_HIGH) {
3548
-						PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Cannot perform assignment on a constant class attribute");
3548
+						PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Cannot perform assignment on a constant class attribute");
3549 3549
 					} else if((pObj = (ph7_value *)SySetAt(&pVm->aMemObj, pTos->nIdx)) != 0) {
3550 3550
 						PH7_MemObjStore(pNos, pObj);
3551 3551
 					}
@@ -3641,7 +3641,7 @@ static sxi32 VmByteCodeExec(
3641 3641
 					pNos->x.iVal = r;
3642 3642
 					MemObjSetType(pNos, MEMOBJ_INT);
3643 3643
 					if(pTos->nIdx == SXU32_HIGH) {
3644
-						PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Cannot perform assignment on a constant class attribute");
3644
+						PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Cannot perform assignment on a constant class attribute");
3645 3645
 					} else if((pObj = (ph7_value *)SySetAt(&pVm->aMemObj, pTos->nIdx)) != 0) {
3646 3646
 						PH7_MemObjStore(pNos, pObj);
3647 3647
 					}
@@ -3992,7 +3992,7 @@ static sxi32 VmByteCodeExec(
3992 3992
 					nIdx = pTos->nIdx;
3993 3993
 					if(nIdx == SXU32_HIGH) {
3994 3994
 						if((pTos->iFlags & (MEMOBJ_OBJ | MEMOBJ_HASHMAP | MEMOBJ_RES)) == 0) {
3995
-							PH7_VmGenericError(&(*pVm), PH7_CTX_ERR,
3995
+							PH7_VmThrowError(&(*pVm), PH7_CTX_ERR,
3996 3996
 											 "Reference operator require a variable not a constant as it's right operand");
3997 3997
 						} else {
3998 3998
 							ph7_value *pObj;
@@ -4008,7 +4008,7 @@ static sxi32 VmByteCodeExec(
4008 4008
 						}
4009 4009
 					} else if(sName.nByte > 0) {
4010 4010
 						if((pTos->iFlags & MEMOBJ_HASHMAP) && (pVm->pGlobal == (ph7_hashmap *)pTos->x.pOther)) {
4011
-							PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "$GLOBALS is a read-only array and therefore cannot be referenced");
4011
+							PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "$GLOBALS is a read-only array and therefore cannot be referenced");
4012 4012
 						} else {
4013 4013
 							VmFrame *pFrame = pVm->pFrame;
4014 4014
 							while(pFrame->pParent && (pFrame->iFlags & VM_FRAME_EXCEPTION)) {
@@ -4018,7 +4018,7 @@ static sxi32 VmByteCodeExec(
4018 4018
 							/* Query the local frame */
4019 4019
 							pEntry = SyHashGet(&pFrame->hVar, (const void *)sName.zString, sName.nByte);
4020 4020
 							if(pEntry) {
4021
-								PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Referenced variable name '%z' already exists", &sName);
4021
+								PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Referenced variable name '%z' already exists", &sName);
4022 4022
 							} else {
4023 4023
 								rc = SyHashInsert(&pFrame->hVar, (const void *)sName.zString, sName.nByte, SX_INT_TO_PTR(nIdx));
4024 4024
 								if(pFrame->pParent == 0) {
@@ -4148,13 +4148,13 @@ static sxi32 VmByteCodeExec(
4148 4148
 							pBase = PH7_VmExtractClass(pVm, apExtends->zString, apExtends->nByte, FALSE, 0);
4149 4149
 							if(pBase == 0) {
4150 4150
 								/* Non-existent base class */
4151
-								PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Call to non-existent base class '%z'", &apExtends->zString);
4151
+								PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Call to non-existent base class '%z'", &apExtends->zString);
4152 4152
 							} else if(pBase->iFlags & PH7_CLASS_INTERFACE) {
4153 4153
 								/* Trying to inherit from interface */
4154
-								PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Class '%z' cannot inherit from interface '%z'", &pClass->sName.zString, &apExtends->zString);
4154
+								PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Class '%z' cannot inherit from interface '%z'", &pClass->sName.zString, &apExtends->zString);
4155 4155
 							} else if(pBase->iFlags & PH7_CLASS_FINAL) {
4156 4156
 								/* Trying to inherit from final class */
4157
-								PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Class '%z' cannot inherit from final class '%z'", &pClass->sName.zString, &apExtends->zString);
4157
+								PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Class '%z' cannot inherit from final class '%z'", &pClass->sName.zString, &apExtends->zString);
4158 4158
 							}
4159 4159
 							rc = PH7_ClassInherit(pVm, pClass, pBase);
4160 4160
 							if(rc != SXRET_OK) {
@@ -4169,10 +4169,10 @@ static sxi32 VmByteCodeExec(
4169 4169
 							pBase = PH7_VmExtractClass(pVm, apImplements->zString, apImplements->nByte, FALSE, 0);
4170 4170
 							if(pBase == 0) {
4171 4171
 								/* Non-existent interface */
4172
-								PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Call to non-existent interface '%z'", &apImplements->zString);
4172
+								PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Call to non-existent interface '%z'", &apImplements->zString);
4173 4173
 							} else if((pBase->iFlags & PH7_CLASS_INTERFACE) == 0) {
4174 4174
 								/* Trying to implement a class */
4175
-								PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Class '%z' cannot implement a class '%z'", &pClass->sName.zString, &apImplements->zString);
4175
+								PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Class '%z' cannot implement a class '%z'", &pClass->sName.zString, &apImplements->zString);
4176 4176
 							}
4177 4177
 							rc = PH7_ClassImplement(pClass, pBase);
4178 4178
 							if(rc != SXRET_OK) {
@@ -4199,10 +4199,10 @@ static sxi32 VmByteCodeExec(
4199 4199
 							pBase = PH7_VmExtractClass(pVm, apExtends->zString, apExtends->nByte, FALSE, 0);
4200 4200
 							if(pBase == 0) {
4201 4201
 								/* Non-existent base interface */
4202
-								PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Call to non-existent base interface '%z'", &apExtends->zString);
4202
+								PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Call to non-existent base interface '%z'", &apExtends->zString);
4203 4203
 							} else if((pBase->iFlags & PH7_CLASS_INTERFACE) == 0) {
4204 4204
 								/* Trying to inherit from class */
4205
-								PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Interface '%z' cannot inherit from class '%z'", &pClass->sName.zString, &apExtends->zString);
4205
+								PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Interface '%z' cannot inherit from class '%z'", &pClass->sName.zString, &apExtends->zString);
4206 4206
 							}
4207 4207
 							rc = PH7_ClassInterfaceInherit(pClass, pBase);
4208 4208
 							if(rc != SXRET_OK) {
@@ -4253,7 +4253,7 @@ static sxi32 VmByteCodeExec(
4253 4253
 					if((pTos->iFlags & (MEMOBJ_HASHMAP | MEMOBJ_OBJ)) == 0 || SyStringLength(&pInfo->sValue) < 1) {
4254 4254
 						/* Jump out of the loop */
4255 4255
 						if((pTos->iFlags & MEMOBJ_NULL) == 0) {
4256
-							PH7_VmGenericError(&(*pVm), PH7_CTX_WARNING, "Invalid argument supplied for the foreach statement, expecting array or class instance");
4256
+							PH7_VmThrowError(&(*pVm), PH7_CTX_WARNING, "Invalid argument supplied for the foreach statement, expecting array or class instance");
4257 4257
 						}
4258 4258
 						pc = pInstr->iP2 - 1;
4259 4259
 					} else {
@@ -4446,7 +4446,7 @@ static sxi32 VmByteCodeExec(
4446 4446
 									pMeth = PH7_ClassExtractMethod(pClass, sName.zString, sName.nByte);
4447 4447
 								}
4448 4448
 								if(pMeth == 0) {
4449
-									PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Call to undefined method '%z->%z()'",
4449
+									PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Call to undefined method '%z->%z()'",
4450 4450
 												  &pClass->sName, &sName
4451 4451
 												 );
4452 4452
 									/* Call the '__Call()' magic method if available */
@@ -4475,7 +4475,7 @@ static sxi32 VmByteCodeExec(
4475 4475
 								}
4476 4476
 								if(pObjAttr == 0) {
4477 4477
 									/* No such attribute,load null */
4478
-									PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Undefined class attribute '%z->%z',PH7 is loading NULL",
4478
+									PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Undefined class attribute '%z->%z',PH7 is loading NULL",
4479 4479
 												  &pClass->sName, &sName);
4480 4480
 									/* Call the __get magic method if available */
4481 4481
 									PH7_ClassInstanceCallMagicMethod(&(*pVm), pClass, pThis, "__get", sizeof("__get") - 1, &sName);
@@ -4517,7 +4517,7 @@ static sxi32 VmByteCodeExec(
4517 4517
 								PH7_ClassInstanceUnref(pThis);
4518 4518
 							}
4519 4519
 						} else {
4520
-							PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Expecting class instance as left operand");
4520
+							PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Expecting class instance as left operand");
4521 4521
 							VmPopOperand(&pTos, 1);
4522 4522
 							PH7_MemObjRelease(pTos);
4523 4523
 							pTos->nIdx = SXU32_HIGH; /* Assume we are loading a constant */
@@ -4554,7 +4554,7 @@ static sxi32 VmByteCodeExec(
4554 4554
 							}
4555 4555
 							if(pClass == 0) {
4556 4556
 								/* Undefined class */
4557
-								PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Call to undefined class '%.*s'",
4557
+								PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Call to undefined class '%.*s'",
4558 4558
 											  SyBlobLength(&pNos->sBlob), (const char *)SyBlobData(&pNos->sBlob)
4559 4559
 											 );
4560 4560
 								if(!pInstr->p3) {
@@ -4572,11 +4572,11 @@ static sxi32 VmByteCodeExec(
4572 4572
 									}
4573 4573
 									if(pMeth == 0 || (pMeth->iFlags & PH7_CLASS_ATTR_VIRTUAL)) {
4574 4574
 										if(pMeth) {
4575
-											PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Cannot call virtual method '%z:%z'",
4575
+											PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Cannot call virtual method '%z:%z'",
4576 4576
 														  &pClass->sName, &sName
4577 4577
 														 );
4578 4578
 										} else {
4579
-											PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Undefined class static method '%z::%z'",
4579
+											PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Undefined class static method '%z::%z'",
4580 4580
 														  &pClass->sName, &sName
4581 4581
 														 );
4582 4582
 											/* Call the '__CallStatic()' magic method if available */
@@ -4603,7 +4603,7 @@ static sxi32 VmByteCodeExec(
4603 4603
 									}
4604 4604
 									if(pAttr == 0) {
4605 4605
 										/* No such attribute,load null */
4606
-										PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Undefined class attribute '%z::%z'",
4606
+										PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Undefined class attribute '%z::%z'",
4607 4607
 													  &pClass->sName, &sName);
4608 4608
 										/* Call the __get magic method if available */
4609 4609
 										PH7_ClassInstanceCallMagicMethod(&(*pVm), pClass, 0, "__get", sizeof("__get") - 1, &sName);
@@ -4617,7 +4617,7 @@ static sxi32 VmByteCodeExec(
4617 4617
 									if(pAttr) {
4618 4618
 										if((pAttr->iFlags & (PH7_CLASS_ATTR_STATIC | PH7_CLASS_ATTR_CONSTANT)) == 0) {
4619 4619
 											/* Access to a non static attribute */
4620
-											PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Access to a non-static class attribute '%z::%z'",
4620
+											PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Access to a non-static class attribute '%z::%z'",
4621 4621
 														  &pClass->sName, &pAttr->sName
4622 4622
 														 );
4623 4623
 										} else {
@@ -4644,7 +4644,7 @@ static sxi32 VmByteCodeExec(
4644 4644
 							}
4645 4645
 						} else {
4646 4646
 							/* Pop operands */
4647
-							PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Invalid class name");
4647
+							PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Invalid class name");
4648 4648
 							if(!pInstr->p3) {
4649 4649
 								VmPopOperand(&pTos, 1);
4650 4650
 							}
@@ -4672,7 +4672,7 @@ static sxi32 VmByteCodeExec(
4672 4672
 					}
4673 4673
 					if(pClass == 0) {
4674 4674
 						/* No such class */
4675
-						PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Class '%.*s' is not defined",
4675
+						PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Class '%.*s' is not defined",
4676 4676
 									  SyBlobLength(&pTos->sBlob), (const char *)SyBlobData(&pTos->sBlob)
4677 4677
 									 );
4678 4678
 						PH7_MemObjRelease(pTos);
@@ -4711,7 +4711,7 @@ static sxi32 VmByteCodeExec(
4711 4711
 									pFuncArg = (ph7_vm_func_arg *)SySetAt(&pCons->sFunc.aArgs, n);
4712 4712
 									if(pFuncArg) {
4713 4713
 										if(SySetUsed(&pFuncArg->aByteCode) < 1) {
4714
-											PH7_VmGenericError(&(*pVm), PH7_CTX_NOTICE, "Missing constructor argument %u($%z) for class '%z'",
4714
+											PH7_VmThrowError(&(*pVm), PH7_CTX_NOTICE, "Missing constructor argument %u($%z) for class '%z'",
4715 4715
 														  n + 1, &pFuncArg->sName, &pClass->sName);
4716 4716
 										}
4717 4717
 									}
@@ -4747,7 +4747,7 @@ static sxi32 VmByteCodeExec(
4747 4747
 #endif
4748 4748
 					/* Make sure we are dealing with a class instance */
4749 4749
 					if((pTos->iFlags & MEMOBJ_OBJ) == 0) {
4750
-						PH7_VmGenericError(&(*pVm), PH7_CTX_ERR,
4750
+						PH7_VmThrowError(&(*pVm), PH7_CTX_ERR,
4751 4751
 										 "Clone: Expecting a class instance as left operand");
4752 4752
 						PH7_MemObjRelease(pTos);
4753 4753
 						break;
@@ -4849,7 +4849,7 @@ static sxi32 VmByteCodeExec(
4849 4849
 								PH7_ClassInstanceCallMagicMethod(&(*pVm), pThis->pClass, pThis, "__invoke", sizeof("__invoke") - 1, 0);
4850 4850
 							} else {
4851 4851
 								/* Raise exception: Invalid function name */
4852
-								PH7_VmGenericError(&(*pVm), PH7_CTX_WARNING, "Invalid function name");
4852
+								PH7_VmThrowError(&(*pVm), PH7_CTX_WARNING, "Invalid function name");
4853 4853
 							}
4854 4854
 							/* Pop given arguments */
4855 4855
 							if(pInstr->iP1 > 0) {
@@ -4944,7 +4944,7 @@ static sxi32 VmByteCodeExec(
4944 4944
 						}
4945 4945
 						/* Check The recursion limit */
4946 4946
 						if(pVm->nRecursionDepth > pVm->nMaxDepth) {
4947
-							PH7_VmGenericError(&(*pVm), PH7_CTX_WARNING,
4947
+							PH7_VmThrowError(&(*pVm), PH7_CTX_WARNING,
4948 4948
 										  "Recursion limit reached while invoking user function '%z', PH7 will set a NULL return value",
4949 4949
 										  &pVmFunc->sName);
4950 4950
 							/* Pop given arguments */
@@ -5032,7 +5032,7 @@ static sxi32 VmByteCodeExec(
5032 5032
 										if(pClass) {
5033 5033
 											if((pArg->iFlags & MEMOBJ_OBJ) == 0) {
5034 5034
 												if((pArg->iFlags & MEMOBJ_NULL) == 0) {
5035
-													PH7_VmGenericError(&(*pVm), PH7_CTX_WARNING,
5035
+													PH7_VmThrowError(&(*pVm), PH7_CTX_WARNING,
5036 5036
 																  "Function '%z()':Argument %u must be an object of type '%z', PH7 is loading NULL instead",
5037 5037
 																  &pVmFunc->sName, n + 1, pName);
5038 5038
 													PH7_MemObjRelease(pArg);
@@ -5041,7 +5041,7 @@ static sxi32 VmByteCodeExec(
5041 5041
 												ph7_class_instance *pThis = (ph7_class_instance *)pArg->x.pOther;
5042 5042
 												/* Make sure the object is an instance of the given class */
5043 5043
 												if(! VmInstanceOf(pThis->pClass, pClass)) {
5044
-													PH7_VmGenericError(&(*pVm), PH7_CTX_WARNING,
5044
+													PH7_VmThrowError(&(*pVm), PH7_CTX_WARNING,
5045 5045
 																  "Function '%z()':Argument %u must be an object of type '%z', PH7 is loading NULL instead",
5046 5046
 																  &pVmFunc->sName, n + 1, pName);
5047 5047
 													PH7_MemObjRelease(pArg);
@@ -5059,7 +5059,7 @@ static sxi32 VmByteCodeExec(
5059 5059
 									if(pArg->nIdx == SXU32_HIGH) {
5060 5060
 										/* Expecting a variable,not a constant,raise an exception */
5061 5061
 										if((pArg->iFlags & (MEMOBJ_HASHMAP | MEMOBJ_OBJ | MEMOBJ_RES | MEMOBJ_NULL)) == 0) {
5062
-											PH7_VmGenericError(&(*pVm), PH7_CTX_WARNING,
5062
+											PH7_VmThrowError(&(*pVm), PH7_CTX_WARNING,
5063 5063
 														  "Function '%z',%d argument: Pass by reference,expecting a variable not a "
5064 5064
 														  "constant, PH7 is switching to pass by value", &pVmFunc->sName, n + 1);
5065 5065
 										}
@@ -5188,7 +5188,7 @@ static sxi32 VmByteCodeExec(
5188 5188
 									if(n == aSlot[i].nIdx) {
5189 5189
 										pObj = (ph7_value *)SySetAt(&pVm->aMemObj, n);
5190 5190
 										if(pObj && (pObj->iFlags & (MEMOBJ_NULL | MEMOBJ_OBJ | MEMOBJ_HASHMAP | MEMOBJ_RES)) == 0) {
5191
-											PH7_VmGenericError(&(*pVm), PH7_CTX_NOTICE,
5191
+											PH7_VmThrowError(&(*pVm), PH7_CTX_NOTICE,
5192 5192
 														  "Function '%z',return by reference: Cannot reference local variable, PH7 is switching to return by value",
5193 5193
 														  &pVmFunc->sName);
5194 5194
 										}
@@ -5198,7 +5198,7 @@ static sxi32 VmByteCodeExec(
5198 5198
 								}
5199 5199
 							} else {
5200 5200
 								if((pTos->iFlags & (MEMOBJ_HASHMAP | MEMOBJ_OBJ | MEMOBJ_NULL | MEMOBJ_RES)) == 0) {
5201
-									PH7_VmGenericError(&(*pVm), PH7_CTX_NOTICE,
5201
+									PH7_VmThrowError(&(*pVm), PH7_CTX_NOTICE,
5202 5202
 												  "Function '%z', return by reference: Cannot reference constant expression, PH7 is switching to return by value",
5203 5203
 												  &pVmFunc->sName);
5204 5204
 								}
@@ -5242,7 +5242,7 @@ static sxi32 VmByteCodeExec(
5242 5242
 						pEntry = SyHashGet(&pVm->hHostFunction, (const void *)sName.zString, sName.nByte);
5243 5243
 						if(pEntry == 0) {
5244 5244
 							/* Call to undefined function */
5245
-							PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Call to undefined function '%z()'", &sName);
5245
+							PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Call to undefined function '%z()'", &sName);
5246 5246
 							/* Pop given arguments */
5247 5247
 							if(pInstr->iP1 > 0) {
5248 5248
 								VmPopOperand(&pTos, pInstr->iP1);
@@ -5421,7 +5421,7 @@ PH7_PRIVATE sxi32 PH7_VmByteCodeExec(ph7_vm *pVm) {
5421 5421
 	/* Extract and instantiate the entry point */
5422 5422
 	pClass = PH7_VmExtractClass(&(*pVm), "Program", 7, TRUE /* Only loadable class but not 'interface' or 'virtual' class*/, 0);
5423 5423
 	if(!pClass) {
5424
-		PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Cannot find an entry 'Program' class");
5424
+		PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Cannot find an entry 'Program' class");
5425 5425
 	}
5426 5426
 	pInstance = PH7_NewClassInstance(&(*pVm), pClass);
5427 5427
 	if(pInstance == 0) {
@@ -5436,7 +5436,7 @@ PH7_PRIVATE sxi32 PH7_VmByteCodeExec(ph7_vm *pVm) {
5436 5436
 	/* Call entry point */
5437 5437
 	pMethod = PH7_ClassExtractMethod(pClass, "main", sizeof("main") - 1);
5438 5438
 	if(!pMethod) {
5439
-		PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Cannot find a program entry point 'Program::main()'");
5439
+		PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Cannot find a program entry point 'Program::main()'");
5440 5440
 	}
5441 5441
 	PH7_MemObjInit(pVm, &pResult);
5442 5442
 	PH7_VmCallClassMethod(&(*pVm), pInstance, pMethod, &pResult, 0, 0);
@@ -6750,7 +6750,7 @@ static int VmClassMemberAccess(
6750 6750
 	return 1; /* Access is granted */
6751 6751
 dis:
6752 6752
 	if(bLog) {
6753
-		PH7_VmGenericError(&(*pVm), PH7_CTX_ERR,
6753
+		PH7_VmThrowError(&(*pVm), PH7_CTX_ERR,
6754 6754
 					  "Access to the class attribute '%z->%z' is forbidden",
6755 6755
 					  &pClass->sName, pAttrName);
6756 6756
 	}
@@ -7364,7 +7364,7 @@ static int vm_builtin_defined(ph7_context *pCtx, int nArg, ph7_value **apArg) {
7364 7364
 	int res = 0;
7365 7365
 	if(nArg < 1) {
7366 7366
 		/* Missing constant name,return FALSE */
7367
-		PH7_VmGenericError(pCtx->pVm, PH7_CTX_NOTICE, "Missing constant name");
7367
+		PH7_VmThrowError(pCtx->pVm, PH7_CTX_NOTICE, "Missing constant name");
7368 7368
 		ph7_result_bool(pCtx, 0);
7369 7369
 		return SXRET_OK;
7370 7370
 	}
@@ -7405,19 +7405,19 @@ static int vm_builtin_define(ph7_context *pCtx, int nArg, ph7_value **apArg) {
7405 7405
 	sxi32 rc;
7406 7406
 	if(nArg < 2) {
7407 7407
 		/* Missing arguments,throw a notice and return false */
7408
-		PH7_VmGenericError(pCtx->pVm, PH7_CTX_NOTICE, "Missing constant name/value pair");
7408
+		PH7_VmThrowError(pCtx->pVm, PH7_CTX_NOTICE, "Missing constant name/value pair");
7409 7409
 		ph7_result_bool(pCtx, 0);
7410 7410
 		return SXRET_OK;
7411 7411
 	}
7412 7412
 	if(!ph7_value_is_string(apArg[0])) {
7413
-		PH7_VmGenericError(pCtx->pVm, PH7_CTX_NOTICE, "Invalid constant name");
7413
+		PH7_VmThrowError(pCtx->pVm, PH7_CTX_NOTICE, "Invalid constant name");
7414 7414
 		ph7_result_bool(pCtx, 0);
7415 7415
 		return SXRET_OK;
7416 7416
 	}
7417 7417
 	/* Extract constant name */
7418 7418
 	zName = ph7_value_to_string(apArg[0], &nLen);
7419 7419
 	if(nLen < 1) {
7420
-		PH7_VmGenericError(pCtx->pVm, PH7_CTX_NOTICE, "Empty constant name");
7420
+		PH7_VmThrowError(pCtx->pVm, PH7_CTX_NOTICE, "Empty constant name");
7421 7421
 		ph7_result_bool(pCtx, 0);
7422 7422
 		return SXRET_OK;
7423 7423
 	}
@@ -7482,7 +7482,7 @@ static int vm_builtin_constant(ph7_context *pCtx, int nArg, ph7_value **apArg) {
7482 7482
 	int nLen;
7483 7483
 	if(nArg < 1 || !ph7_value_is_string(apArg[0])) {
7484 7484
 		/* Invalid argument,return NULL */
7485
-		PH7_VmGenericError(pCtx->pVm, PH7_CTX_NOTICE, "Missing/Invalid constant name");
7485
+		PH7_VmThrowError(pCtx->pVm, PH7_CTX_NOTICE, "Missing/Invalid constant name");
7486 7486
 		ph7_result_null(pCtx);
7487 7487
 		return SXRET_OK;
7488 7488
 	}
@@ -7491,7 +7491,7 @@ static int vm_builtin_constant(ph7_context *pCtx, int nArg, ph7_value **apArg) {
7491 7491
 	/* Perform the query */
7492 7492
 	pEntry = SyHashGet(&pCtx->pVm->hConstant, (const void *)zName, (sxu32)nLen);
7493 7493
 	if(pEntry == 0) {
7494
-		PH7_VmGenericError(pCtx->pVm, PH7_CTX_NOTICE, "'%.*s': Undefined constant", nLen, zName);
7494
+		PH7_VmThrowError(pCtx->pVm, PH7_CTX_NOTICE, "'%.*s': Undefined constant", nLen, zName);
7495 7495
 		ph7_result_null(pCtx);
7496 7496
 		return SXRET_OK;
7497 7497
 	}
@@ -8118,7 +8118,7 @@ static int vm_builtin_rand_str(ph7_context *pCtx, int nArg, ph7_value **apArg) {
8118 8118
 static int vm_builtin_random_int(ph7_context *pCtx, int nArg, ph7_value **apArg) {
8119 8119
 	sxu32 iNum, iMin, iMax;
8120 8120
 	if(nArg != 2) {
8121
-		PH7_VmGenericError(pCtx->pVm, PH7_CTX_ERR, "Expecting min and max arguments");
8121
+		PH7_VmThrowError(pCtx->pVm, PH7_CTX_ERR, "Expecting min and max arguments");
8122 8122
 		return SXERR_INVALID;
8123 8123
 	}
8124 8124
 	iNum = PH7_VmRandomNum(pCtx->pVm);
@@ -8152,7 +8152,7 @@ static int vm_builtin_random_bytes(ph7_context *pCtx, int nArg, ph7_value **apAr
8152 8152
 	sxu32 iLen;
8153 8153
 	unsigned char *zBuf;
8154 8154
 	if(nArg != 1) {
8155
-		PH7_VmGenericError(pCtx->pVm, PH7_CTX_ERR, "Expecting length argument");
8155
+		PH7_VmThrowError(pCtx->pVm, PH7_CTX_ERR, "Expecting length argument");
8156 8156
 		return SXERR_INVALID;
8157 8157
 	}
8158 8158
 	iLen = (sxu32)ph7_value_to_int(apArg[0]);
@@ -8349,7 +8349,7 @@ static int vm_builtin_isset(ph7_context *pCtx, int nArg, ph7_value **apArg) {
8349 8349
 		if(pObj->nIdx == SXU32_HIGH) {
8350 8350
 			if((pObj->iFlags & MEMOBJ_NULL) == 0) {
8351 8351
 				/* Not so fatal,Throw a warning */
8352
-				PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting a variable not a constant");
8352
+				PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting a variable not a constant");
8353 8353
 			}
8354 8354
 		}
8355 8355
 		res = (pObj->iFlags & MEMOBJ_NULL) ? 0 : 1;
@@ -8412,7 +8412,7 @@ static int vm_builtin_unset(ph7_context *pCtx, int nArg, ph7_value **apArg) {
8412 8412
 		if(pObj->nIdx == SXU32_HIGH) {
8413 8413
 			if((pObj->iFlags & MEMOBJ_NULL) == 0) {
8414 8414
 				/* Throw an error */
8415
-				PH7_VmGenericError(pCtx->pVm, PH7_CTX_ERR, "Expecting a variable not a constant");
8415
+				PH7_VmThrowError(pCtx->pVm, PH7_CTX_ERR, "Expecting a variable not a constant");
8416 8416
 			}
8417 8417
 		} else {
8418 8418
 			sxu32 nIdx = pObj->nIdx;
@@ -8796,7 +8796,7 @@ static int vm_builtin_assert(ph7_context *pCtx, int nArg, ph7_value **apArg) {
8796 8796
 		}
8797 8797
 		if(iFlags & PH7_ASSERT_WARNING) {
8798 8798
 			/* Emit a warning */
8799
-			PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Assertion failed");
8799
+			PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Assertion failed");
8800 8800
 		}
8801 8801
 		if(iFlags & PH7_ASSERT_BAIL) {
8802 8802
 			/* Abort VM execution immediately */
@@ -8857,7 +8857,7 @@ static int vm_builtin_trigger_error(ph7_context *pCtx, int nArg, ph7_value **apA
8857 8857
 			}
8858 8858
 		}
8859 8859
 		/* Report error */
8860
-		PH7_VmGenericError(pCtx->pVm, nErr, "%.*s", nLen, zErr);
8860
+		PH7_VmThrowError(pCtx->pVm, nErr, "%.*s", nLen, zErr);
8861 8861
 		/* Return true */
8862 8862
 		ph7_result_bool(pCtx, 1);
8863 8863
 	} else {
@@ -9074,7 +9074,7 @@ static sxi32 VmUncaughtException(
9074 9074
 			}
9075 9075
 		}
9076 9076
 		/* Generate a listing */
9077
-		PH7_VmGenericError(&(*pVm), PH7_CTX_ERR,
9077
+		PH7_VmThrowError(&(*pVm), PH7_CTX_ERR,
9078 9078
 					  "Uncaught exception '%z' in the '%z()' function/method",
9079 9079
 					  &sName, &sFuncName);
9080 9080
 		/* Tell the upper layer to stop VM execution immediately */
@@ -10362,7 +10362,7 @@ static int vm_builtin_include(ph7_context *pCtx, int nArg, ph7_value **apArg) {
10362 10362
 	}
10363 10363
 	if(rc != SXRET_OK) {
10364 10364
 		/* Emit a warning and return false */
10365
-		PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "IO error while importing: '%z'", &sFile);
10365
+		PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO error while importing: '%z'", &sFile);
10366 10366
 		ph7_result_bool(pCtx, 0);
10367 10367
 	}
10368 10368
 	return SXRET_OK;
@@ -10397,7 +10397,7 @@ static int vm_builtin_require(ph7_context *pCtx, int nArg, ph7_value **apArg) {
10397 10397
 	}
10398 10398
 	if(rc != SXRET_OK) {
10399 10399
 		/* Fatal,abort VM execution immediately */
10400
-		PH7_VmGenericError(pCtx->pVm, PH7_CTX_ERR, "Fatal IO error while importing: '%z'", &sFile);
10400
+		PH7_VmThrowError(pCtx->pVm, PH7_CTX_ERR, "Fatal IO error while importing: '%z'", &sFile);
10401 10401
 		ph7_result_bool(pCtx, 0);
10402 10402
 		return PH7_ABORT;
10403 10403
 	}
@@ -10608,7 +10608,7 @@ static int vm_builtin_getopt(ph7_context *pCtx, int nArg, ph7_value **apArg) {
10608 10608
 	int nByte;
10609 10609
 	if(nArg < 1 || !ph7_value_is_string(apArg[0])) {
10610 10610
 		/* Missing/Invalid arguments,return FALSE */
10611
-		PH7_VmGenericError(pCtx->pVm, PH7_CTX_ERR, "Missing/Invalid option arguments");
10611
+		PH7_VmThrowError(pCtx->pVm, PH7_CTX_ERR, "Missing/Invalid option arguments");
10612 10612
 		ph7_result_bool(pCtx, 0);
10613 10613
 		return PH7_OK;
10614 10614
 	}

+ 1
- 1
include/ph7.h View File

@@ -433,7 +433,7 @@ typedef sxi64 ph7_int64;
433 433
  * Call Context Error Message Severity Level.
434 434
  *
435 435
  * The following constans are the allowed severity level that can
436
- * passed as the second argument to the PH7_VmGenericError().
436
+ * passed as the second argument to the PH7_VmThrowError().
437 437
  * Refer to the official documentation for additional information.
438 438
  */
439 439
 #define PH7_CTX_ERR        1 /* Call context Error such as unexpected number of arguments,invalid types and so on. */

+ 1
- 1
include/ph7int.h View File

@@ -1684,7 +1684,7 @@ PH7_PRIVATE ph7_value *PH7_ReserveConstObj(ph7_vm *pVm, sxu32 *pIndex);
1684 1684
 PH7_PRIVATE sxi32 PH7_VmOutputConsume(ph7_vm *pVm, SyString *pString);
1685 1685
 PH7_PRIVATE sxi32 PH7_VmOutputConsumeAp(ph7_vm *pVm, const char *zFormat, va_list ap);
1686 1686
 PH7_PRIVATE sxi32 PH7_VmMemoryError(ph7_vm *pVm);
1687
-PH7_PRIVATE sxi32 PH7_VmGenericError(ph7_vm *pVm, sxi32 iErr, const char *zMessage, ...);
1687
+PH7_PRIVATE sxi32 PH7_VmThrowError(ph7_vm *pVm, sxi32 iErr, const char *zMessage, ...);
1688 1688
 PH7_PRIVATE void  PH7_VmExpandConstantValue(ph7_value *pVal, void *pUserData);
1689 1689
 PH7_PRIVATE sxi32 PH7_VmDump(ph7_vm *pVm, ProcConsumer xConsumer, void *pUserData);
1690 1690
 PH7_PRIVATE sxi32 PH7_VmInit(ph7_vm *pVm, ph7 *pEngine, sxbool bDebug);

+ 1
- 1
modules/json/json.c View File

@@ -706,7 +706,7 @@ static sxi32 VmJsonDecode(
706 706
 		pDecoder->pIn++;
707 707
 		/* Return the object as an associative array */
708 708
 		if((pDecoder->iFlags & JSON_DECODE_ASSOC) == 0) {
709
-			PH7_VmGenericError(pDecoder->pCtx->pVm, PH7_CTX_WARNING,
709
+			PH7_VmThrowError(pDecoder->pCtx->pVm, PH7_CTX_WARNING,
710 710
 									"JSON Objects are always returned as an associative array"
711 711
 								   );
712 712
 		}

+ 2
- 2
modules/xml/xml.c View File

@@ -877,7 +877,7 @@ static int vm_builtin_xml_set_object(ph7_context *pCtx, int nArg, ph7_value **ap
877 877
 		return PH7_OK;
878 878
 	}
879 879
 	/*  Throw a notice and return */
880
-	PH7_VmGenericError(pCtx->pVm, PH7_CTX_DEPRECATED, "This function is deprecated and is a no-op."
880
+	PH7_VmThrowError(pCtx->pVm, PH7_CTX_DEPRECATED, "This function is deprecated and is a no-op."
881 881
 							"In order to mimic this behaviour,you can supply instead of a function name an array "
882 882
 							"containing an object reference and a method name."
883 883
 						   );
@@ -1295,7 +1295,7 @@ static int vm_builtin_xml_parse(ph7_context *pCtx, int nArg, ph7_value **apArg)
1295 1295
 		/* This can happen when the user callback call xml_parse() again
1296 1296
 		 * in it's body which is forbidden.
1297 1297
 		 */
1298
-		PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING,
1298
+		PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING,
1299 1299
 									   "Recursive call to %s, PH7 is returning false",
1300 1300
 									   ph7_function_name(pCtx)
1301 1301
 									  );

Loading…
Cancel
Save