setCatchHandler.ts 801 B

123456789101112131415161718192021222324252627
  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 {Handler} from './_types.js';
  9. import './_version.js';
  10. /**
  11. * If a Route throws an error while handling a request, this `handler`
  12. * will be called and given a chance to provide a response.
  13. *
  14. * @param {module:workbox-routing~handlerCallback} handler A callback
  15. * function that returns a Promise resulting in a Response.
  16. *
  17. * @memberof module:workbox-routing
  18. */
  19. function setCatchHandler(handler: Handler) {
  20. const defaultRouter = getOrCreateDefaultRouter();
  21. defaultRouter.setCatchHandler(handler);
  22. }
  23. export {setCatchHandler}