setCatchHandler.js 761 B

1234567891011121314151617181920212223
  1. /*
  2. Copyright 2019 Google LLC
  3. Use of this source code is governed by an MIT-style
  4. license that can be found in the LICENSE file or at
  5. https://opensource.org/licenses/MIT.
  6. */
  7. import { getOrCreateDefaultRouter } from './utils/getOrCreateDefaultRouter.js';
  8. import './_version.js';
  9. /**
  10. * If a Route throws an error while handling a request, this `handler`
  11. * will be called and given a chance to provide a response.
  12. *
  13. * @param {module:workbox-routing~handlerCallback} handler A callback
  14. * function that returns a Promise resulting in a Response.
  15. *
  16. * @memberof module:workbox-routing
  17. */
  18. function setCatchHandler(handler) {
  19. const defaultRouter = getOrCreateDefaultRouter();
  20. defaultRouter.setCatchHandler(handler);
  21. }
  22. export { setCatchHandler };