| 1336 | } |
| 1337 | |
| 1338 | void fxThrowMessage(txMachine* the, txString path, txInteger line, txError error, txString format, ...) |
| 1339 | { |
| 1340 | char message[128] = ""; |
| 1341 | txSize length = 0; |
| 1342 | va_list arguments; |
| 1343 | txSlot* slot; |
| 1344 | va_start(arguments, format); |
| 1345 | c_vsnprintf(message, sizeof(message), format, arguments); |
| 1346 | va_end(arguments); |
| 1347 | |
| 1348 | //?? |
| 1349 | length = (txSize)c_strlen(message) - 1; |
| 1350 | while (length && (0x80 & message[length])) |
| 1351 | message[length--] = 0; |
| 1352 | |
| 1353 | #ifdef mxDebug |
| 1354 | if (!the->debugEval) { |
| 1355 | c_strncat(message, " (in ", sizeof(message) - mxStringLength(message) - 1); |
| 1356 | length = (txSize)c_strlen(message); |
| 1357 | fxBufferFrameName(the, message + length, sizeof(message) - length, the->frame, ")"); |
| 1358 | } |
| 1359 | #endif |
| 1360 | |
| 1361 | if ((error <= XS_NO_ERROR) || (XS_ERROR_COUNT <= error)) |
| 1362 | error = XS_UNKNOWN_ERROR; |
| 1363 | |
| 1364 | slot = fxNewSlot(the); |
| 1365 | slot->kind = XS_INSTANCE_KIND; |
| 1366 | slot->value.instance.garbage = C_NULL; |
| 1367 | slot->value.instance.prototype = mxErrorPrototypes(error).value.reference; |
| 1368 | mxException.kind = XS_REFERENCE_KIND; |
| 1369 | mxException.value.reference = slot; |
| 1370 | slot = slot->next = fxNewSlot(the); |
| 1371 | slot->flag = XS_INTERNAL_FLAG; |
| 1372 | slot->kind = XS_ERROR_KIND; |
| 1373 | slot->value.error.info = C_NULL; |
| 1374 | slot->value.error.which = error; |
| 1375 | if (gxDefaults.captureErrorStack) |
| 1376 | gxDefaults.captureErrorStack(the, slot, the->frame); |
| 1377 | slot = fxNextStringProperty(the, slot, message, mxID(_message), XS_DONT_ENUM_FLAG); |
| 1378 | #ifdef mxDebug |
| 1379 | fxDebugThrow(the, path, line, "throw"); |
| 1380 | #endif |
| 1381 | fxJump(the); |
| 1382 | } |
| 1383 | |
| 1384 | /* Debugger */ |
| 1385 |
no test coverage detected