index.js 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. var __extends = (this && this.__extends) || (function () {
  2. var extendStatics = function (d, b) {
  3. extendStatics = Object.setPrototypeOf ||
  4. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  5. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  6. return extendStatics(d, b);
  7. };
  8. return function (d, b) {
  9. extendStatics(d, b);
  10. function __() { this.constructor = d; }
  11. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  12. };
  13. })();
  14. export var QiniuErrorName;
  15. (function (QiniuErrorName) {
  16. // 输入错误
  17. QiniuErrorName["InvalidFile"] = "InvalidFile";
  18. QiniuErrorName["InvalidToken"] = "InvalidToken";
  19. QiniuErrorName["InvalidMetadata"] = "InvalidMetadata";
  20. QiniuErrorName["InvalidChunkSize"] = "InvalidChunkSize";
  21. QiniuErrorName["InvalidCustomVars"] = "InvalidCustomVars";
  22. QiniuErrorName["NotAvailableUploadHost"] = "NotAvailableUploadHost";
  23. // 缓存相关
  24. QiniuErrorName["ReadCacheFailed"] = "ReadCacheFailed";
  25. QiniuErrorName["InvalidCacheData"] = "InvalidCacheData";
  26. QiniuErrorName["WriteCacheFailed"] = "WriteCacheFailed";
  27. QiniuErrorName["RemoveCacheFailed"] = "RemoveCacheFailed";
  28. // 图片压缩模块相关
  29. QiniuErrorName["GetCanvasContextFailed"] = "GetCanvasContextFailed";
  30. QiniuErrorName["UnsupportedFileType"] = "UnsupportedFileType";
  31. // 运行环境相关
  32. QiniuErrorName["FileReaderReadFailed"] = "FileReaderReadFailed";
  33. QiniuErrorName["NotAvailableXMLHttpRequest"] = "NotAvailableXMLHttpRequest";
  34. QiniuErrorName["InvalidProgressEventTarget"] = "InvalidProgressEventTarget";
  35. // 请求错误
  36. QiniuErrorName["RequestError"] = "RequestError";
  37. })(QiniuErrorName || (QiniuErrorName = {}));
  38. var QiniuError = /** @class */ (function () {
  39. function QiniuError(name, message) {
  40. this.name = name;
  41. this.message = message;
  42. this.stack = new Error().stack;
  43. }
  44. return QiniuError;
  45. }());
  46. export { QiniuError };
  47. var QiniuRequestError = /** @class */ (function (_super) {
  48. __extends(QiniuRequestError, _super);
  49. function QiniuRequestError(code, reqId, message, data) {
  50. var _this = _super.call(this, QiniuErrorName.RequestError, message) || this;
  51. _this.code = code;
  52. _this.reqId = reqId;
  53. /**
  54. * @description 标记当前的 error 类型是一个 QiniuRequestError
  55. * @deprecated 下一个大版本将会移除,不推荐使用,推荐直接使用 instanceof 进行判断
  56. */
  57. _this.isRequestError = true;
  58. _this.data = data;
  59. return _this;
  60. }
  61. return QiniuRequestError;
  62. }(QiniuError));
  63. export { QiniuRequestError };
  64. /**
  65. * @description 由于跨域、证书错误、断网、host 解析失败、系统拦截等原因导致的错误
  66. */
  67. var QiniuNetworkError = /** @class */ (function (_super) {
  68. __extends(QiniuNetworkError, _super);
  69. function QiniuNetworkError(message, reqId) {
  70. if (reqId === void 0) { reqId = ''; }
  71. return _super.call(this, 0, reqId, message) || this;
  72. }
  73. return QiniuNetworkError;
  74. }(QiniuRequestError));
  75. export { QiniuNetworkError };
  76. //# sourceMappingURL=index.js.map