* Verifies that return value of configured `beforeSend` or `beforeSendTransaction` is of expected type, and returns the value if so.
( beforeSendResult: PromiseLike<Event | null> | Event | null, beforeSendLabel: string, )
| 1618 | * Verifies that return value of configured `beforeSend` or `beforeSendTransaction` is of expected type, and returns the value if so. |
| 1619 | */ |
| 1620 | function _validateBeforeSendResult( |
| 1621 | beforeSendResult: PromiseLike<Event | null> | Event | null, |
| 1622 | beforeSendLabel: string, |
| 1623 | ): PromiseLike<Event | null> | Event | null { |
| 1624 | const invalidValueError = `${beforeSendLabel} must return \`null\` or a valid event.`; |
| 1625 | if (isThenable(beforeSendResult)) { |
| 1626 | return beforeSendResult.then( |
| 1627 | event => { |
| 1628 | if (!isPlainObject(event) && event !== null) { |
| 1629 | throw _makeInternalError(invalidValueError); |
| 1630 | } |
| 1631 | return event; |
| 1632 | }, |
| 1633 | e => { |
| 1634 | throw _makeInternalError(`${beforeSendLabel} rejected with ${e}`); |
| 1635 | }, |
| 1636 | ); |
| 1637 | } else if (!isPlainObject(beforeSendResult) && beforeSendResult !== null) { |
| 1638 | throw _makeInternalError(invalidValueError); |
| 1639 | } |
| 1640 | return beforeSendResult; |
| 1641 | } |
| 1642 | |
| 1643 | /** |
| 1644 | * Process the matching `beforeSendXXX` callback. |
no test coverage detected