errors.js 924 B

12345678910111213141516171819202122232425262728
  1. import { getXHRResponse } from './getXHRResponse';
  2. import { createErrorClass } from '../util/createErrorClass';
  3. export const AjaxError = createErrorClass((_super) => function AjaxErrorImpl(message, xhr, request) {
  4. this.message = message;
  5. this.name = 'AjaxError';
  6. this.xhr = xhr;
  7. this.request = request;
  8. this.status = xhr.status;
  9. this.responseType = xhr.responseType;
  10. let response;
  11. try {
  12. response = getXHRResponse(xhr);
  13. }
  14. catch (err) {
  15. response = xhr.responseText;
  16. }
  17. this.response = response;
  18. });
  19. export const AjaxTimeoutError = (() => {
  20. function AjaxTimeoutErrorImpl(xhr, request) {
  21. AjaxError.call(this, 'ajax timeout', xhr, request);
  22. this.name = 'AjaxTimeoutError';
  23. return this;
  24. }
  25. AjaxTimeoutErrorImpl.prototype = Object.create(AjaxError.prototype);
  26. return AjaxTimeoutErrorImpl;
  27. })();
  28. //# sourceMappingURL=errors.js.map