home
  • Blog
  • Home
  • Projects
    • Ember
    • EmberData
    • Ember CLI
6.7
  • Packages
    • @ember/application
    • @ember/application/namespace
    • @ember/array
    • @ember/array/proxy
    • @ember/canary-features
    • @ember/component
    • @ember/component/template-only
    • @ember/controller
    • @ember/debug
    • @ember/debug/container-debug-adapter
    • @ember/debug/data-adapter
    • @ember/destroyable
    • @ember/engine
    • @ember/helper
    • @ember/object
    • @ember/object/core
    • @ember/object/evented
    • @ember/object/mixin
    • @ember/object/observable
    • @ember/object/promise-proxy-mixin
    • @ember/object/proxy
    • @ember/owner
    • @ember/renderer
    • @ember/routing
    • @ember/routing/hash-location
    • @ember/routing/history-location
    • @ember/routing/location
    • @ember/routing/none-location
    • @ember/routing/route
    • @ember/routing/route-info
    • @ember/routing/router
    • @ember/routing/router-service
    • @ember/routing/transition
    • @ember/runloop
    • @ember/service
    • @ember/template
    • @ember/test
    • @ember/utils
    • @glimmer/component
    • @glimmer/tracking
    • @glimmer/tracking/primitives/cache
    • rsvp
  • Classes
    • Application
    • ApplicationInstance
    • ApplicationInstance.BootOptions
    • ArrayProxy
    • Component
    • ComputedProperty
    • ContainerDebugAdapter
    • CoreObject
    • DataAdapter
    • Ember.Controller
    • Ember.NativeArray
    • Ember.Templates.helpers
    • Ember.Test
    • Ember.Test.QUnitAdapter
    • EmberArray
    • EmberENV
    • EmberObject
    • EmberRouter
    • Engine
    • EngineInstance
    • EventTarget
    • Evented
    • Factory
    • FactoryManager
    • FullName
    • HashLocation
    • Helper
    • HistoryLocation
    • Location
    • Mixin
    • MutableArray
    • Namespace
    • NoneLocation
    • ObjectProxy
    • Observable
    • Owner
    • Promise
    • PromiseProxyMixin
    • RegisterOptions
    • Renderer
    • Resolver
    • Route
    • RouteInfo
    • RouteInfoWithAttributes
    • RouterService
    • SafeString
    • Service
    • TestAdapter
    • Transition
    • TrustedHTML

Function


rethrow (reason) public

Module: rsvp

Defined in node_modules/rsvp/lib/rsvp/rethrow.js:1

reason
Error

reason the promise became rejected.

rethrow will rethrow an error on the next turn of the JavaScript event loop in order to aid debugging.

Promises A+ specifies that any exceptions that occur with a promise must be caught by the promises implementation and bubbled to the last handler. For this reason, it is recommended that you always specify a second rejection handler function to then. However, rethrow will throw the exception outside of the promise, so it bubbles up to your console if in the browser, or domain/cause uncaught exception in Node. rethrow will also throw the error again so the error can be handled by the promise per the spec.

import { rethrow } from 'rsvp';

function throws(){
  throw new Error('Whoops!');
}

let promise = new Promise(function(resolve, reject){
  throws();
});

promise.catch(rethrow).then(function(){
  // Code here doesn't run because the promise became rejected due to an
  // error!
}, function (err){
  // handle the error here
});

The 'Whoops' error will be thrown on the next turn of the event loop and you can watch for it in your console. You can also handle it using a rejection handler given to .then or .catch on the returned promise.

Team Sponsors Security Legal Branding Community Guidelines
Twitter GitHub Discord Mastodon

If you want help you can contact us by email, open an issue, or get realtime help by joining the Ember Discord.

© Copyright 2025 - Tilde Inc.
Ember.js is free, open source and always will be.


Ember is generously supported by
blue Created with Sketch.