| 509 | // actually occurred, rather than the place where the exception was |
| 510 | // thrown. |
| 511 | var exception = function (error) { |
| 512 | if (! currentJob.get()) { |
| 513 | // XXX this may be the wrong place to do this, but it makes syntax errors in |
| 514 | // files loaded via isopack.load have context. |
| 515 | if (error instanceof files.FancySyntaxError) { |
| 516 | error = new Error("Syntax error: " + error.message + " at " + |
| 517 | error.file + ":" + error.line + ":" + error.column); |
| 518 | } |
| 519 | throw error; |
| 520 | } |
| 521 | |
| 522 | var message = error.message; |
| 523 | |
| 524 | if (error instanceof files.FancySyntaxError) { |
| 525 | // No stack, because FancySyntaxError isn't a real Error and has no stack |
| 526 | // property! |
| 527 | currentJob.get().addMessage({ |
| 528 | message: message, |
| 529 | file: error.file, |
| 530 | line: error.line, |
| 531 | column: error.column |
| 532 | }); |
| 533 | } else { |
| 534 | var parsed = parseStack.parse(error); |
| 535 | |
| 536 | // If there is a part inside the fiber, that's the one we want. Otherwise, |
| 537 | // use the one outside. |
| 538 | var stack = parsed.insideFiber || parsed.outsideFiber; |
| 539 | if (stack && stack.length > 0) { |
| 540 | var locus = stack[0]; |
| 541 | currentJob.get().addMessage({ |
| 542 | message: message, |
| 543 | stack: stack, |
| 544 | func: locus.func, |
| 545 | file: locus.file, |
| 546 | line: locus.line, |
| 547 | column: locus.column |
| 548 | }); |
| 549 | } else { |
| 550 | currentJob.get().addMessage({ |
| 551 | message: message |
| 552 | }); |
| 553 | } |
| 554 | } |
| 555 | }; |
| 556 | |
| 557 | var assertInJob = function () { |
| 558 | if (! currentJob.get()) { |