MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / fxCheckUnhandledRejections

Function fxCheckUnhandledRejections

xs/sources/xsPromise.c:233–276  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

231}
232
233void fxCheckUnhandledRejections(txMachine* the, txBoolean atExit)
234{
235 txSlot* list = &mxUnhandledPromises;
236 txSlot** address = &list->value.reference->next;
237 txSlot* slot;
238 if (atExit) {
239 txIndex count = 0;
240 while ((slot = *address)) {
241 #if mxReportUnhandledRejections
242 if (slot->value.weakRef.target == C_NULL) {
243 fprintf(stderr, "# garbage collected promise\n");
244 }
245 else {
246 txSlot* property = mxPromiseEnvironment(slot->value.weakRef.target);
247 if (property && property->ID) {
248 fprintf(stderr, "%s:%d\n", fxGetKeyName(the, property->ID), property->value.environment.line);
249 }
250 }
251 #endif
252 slot = slot->next;
253 *address = slot->next;
254 mxException.value = slot->value;
255 mxException.kind = slot->kind;
256 count++;
257 }
258 if (count > 0)
259 fxAbort(the, XS_UNHANDLED_REJECTION_EXIT);
260 }
261 else {
262 while ((slot = *address)) {
263 if (slot->value.weakRef.target == C_NULL) {
264 slot = slot->next;
265 *address = slot->next;
266 mxException.value = slot->value;
267 mxException.kind = slot->kind;
268 fxAbort(the, XS_UNHANDLED_REJECTION_EXIT);
269 }
270 else {
271 slot = slot->next;
272 address = &slot->next;
273 }
274 }
275 }
276}
277
278void fxCombinePromises(txMachine* the, txInteger which)
279{

Callers 4

fuzzFunction · 0.85
mainFunction · 0.85
fxRunBundleFunction · 0.85
fxEndJobFunction · 0.85

Calls 2

fxGetKeyNameFunction · 0.85
fxAbortFunction · 0.70

Tested by

no test coverage detected