(options)
| 3491 | ]; |
| 3492 | |
| 3493 | function ExceptionFormatter(options) { |
| 3494 | const jasmineFile = |
| 3495 | (options && options.jasmineFile) || j$.util.jasmineFile(); |
| 3496 | this.message = function(error) { |
| 3497 | let message = ''; |
| 3498 | |
| 3499 | if (error.jasmineMessage) { |
| 3500 | message += error.jasmineMessage; |
| 3501 | } else if (error.name && error.message) { |
| 3502 | message += error.name + ': ' + error.message; |
| 3503 | } else if (error.message) { |
| 3504 | message += error.message; |
| 3505 | } else { |
| 3506 | message += error.toString() + ' thrown'; |
| 3507 | } |
| 3508 | |
| 3509 | if (error.fileName || error.sourceURL) { |
| 3510 | message += ' in ' + (error.fileName || error.sourceURL); |
| 3511 | } |
| 3512 | |
| 3513 | if (error.line || error.lineNumber) { |
| 3514 | message += ' (line ' + (error.line || error.lineNumber) + ')'; |
| 3515 | } |
| 3516 | |
| 3517 | return message; |
| 3518 | }; |
| 3519 | |
| 3520 | this.stack = function(error, { omitMessage } = {}) { |
| 3521 | if (!error || !error.stack) { |
| 3522 | return null; |
| 3523 | } |
| 3524 | |
| 3525 | const lines = this.stack_(error, { |
| 3526 | messageHandling: omitMessage ? 'omit' : undefined |
| 3527 | }); |
| 3528 | return lines.join('\n'); |
| 3529 | }; |
| 3530 | |
| 3531 | // messageHandling can be falsy (unspecified), 'omit', or 'require' |
| 3532 | this.stack_ = function(error, { messageHandling }) { |
| 3533 | let lines = formatProperties(error).split('\n'); |
| 3534 | |
| 3535 | if (lines[lines.length - 1] === '') { |
| 3536 | lines.pop(); |
| 3537 | } |
| 3538 | |
| 3539 | const stackTrace = new j$.StackTrace(error); |
| 3540 | lines = lines.concat(filterJasmine(stackTrace)); |
| 3541 | |
| 3542 | if (messageHandling === 'require') { |
| 3543 | lines.unshift(stackTrace.message || 'Error: ' + error.message); |
| 3544 | } else if (messageHandling !== 'omit' && stackTrace.message) { |
| 3545 | lines.unshift(stackTrace.message); |
| 3546 | } |
| 3547 | |
| 3548 | if (error.cause) { |
| 3549 | const substack = this.stack_(error.cause, { |
| 3550 | messageHandling: 'require' |
nothing calls this directly
no test coverage detected