c4a96061a0c7a6c5858cdc47c85dc9addc97184554eb9153d3fbd377f498e54faf8a89efd395ef41abae75a1679434cf51052471d2041d12f6ad558366bb50 902 B

123456789101112131415161718192021222324
  1. import { config } from '../config';
  2. import { timeoutProvider } from '../scheduler/timeoutProvider';
  3. /**
  4. * Handles an error on another job either with the user-configured {@link onUnhandledError},
  5. * or by throwing it on that new job so it can be picked up by `window.onerror`, `process.on('error')`, etc.
  6. *
  7. * This should be called whenever there is an error that is out-of-band with the subscription
  8. * or when an error hits a terminal boundary of the subscription and no error handler was provided.
  9. *
  10. * @param err the error to report
  11. */
  12. export function reportUnhandledError(err: any) {
  13. timeoutProvider.setTimeout(() => {
  14. const { onUnhandledError } = config;
  15. if (onUnhandledError) {
  16. // Execute the user-configured error handler.
  17. onUnhandledError(err);
  18. } else {
  19. // Throw so it is picked up by the runtime's uncaught error mechanism.
  20. throw err;
  21. }
  22. });
  23. }