UNPKG

ember-source

Version:

A JavaScript framework for creating ambitious web applications

55 lines (52 loc) 1.7 kB
import { c as configure, o as on, R as RSVP } from '../../../../../shared-chunks/rsvp-DaQAFb0W.js'; import { _backburner, _rsvpErrorQueue } from '../../../../runloop/index.js'; import { getDispatchOverride } from '../../../error-handling/index.js'; import '../../../../debug/index.js'; import { isDevelopingApp } from '@embroider/macros'; import { assert } from '../../../../debug/lib/assert.js'; configure('async', (callback, promise) => { _backburner.schedule('actions', null, callback, promise); }); configure('after', cb => { _backburner.schedule(_rsvpErrorQueue, null, cb); }); on('error', onerrorDefault); function onerrorDefault(reason) { let error = errorFor(reason); if (error) { let overrideDispatch = getDispatchOverride(); if (overrideDispatch) { overrideDispatch(error); } else { throw error; } } } function errorFor(reason) { if (!reason) return; let withErrorThrown = reason; if (withErrorThrown.errorThrown) { return unwrapErrorThrown(withErrorThrown); } let withName = reason; if (withName.name === 'UnrecognizedURLError') { (isDevelopingApp() && !(false) && assert(`The URL '${withName.message}' did not match any routes in your application`, false)); // @ts-expect-error We'll hit this if the assert is stripped return; } if (reason.name === 'TransitionAborted') { return; } return reason; } function unwrapErrorThrown(reason) { let error = reason.errorThrown; if (typeof error === 'string') { error = new Error(error); } Object.defineProperty(error, '__reason_with_error_thrown__', { value: reason, enumerable: false }); return error; } export { RSVP as default, onerrorDefault };