Sin descripción
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

error.js 1.3KB

1234567891011121314151617181920212223242526272829
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.isBillingError = exports.FirebaseError = void 0;
  4. const lodash_1 = require("lodash");
  5. const DEFAULT_CHILDREN = [];
  6. const DEFAULT_EXIT = 1;
  7. const DEFAULT_STATUS = 500;
  8. class FirebaseError extends Error {
  9. constructor(message, options = {}) {
  10. super();
  11. this.name = "FirebaseError";
  12. this.children = (0, lodash_1.defaultTo)(options.children, DEFAULT_CHILDREN);
  13. this.context = options.context;
  14. this.exit = (0, lodash_1.defaultTo)(options.exit, DEFAULT_EXIT);
  15. this.message = message;
  16. this.original = options.original;
  17. this.status = (0, lodash_1.defaultTo)(options.status, DEFAULT_STATUS);
  18. }
  19. }
  20. exports.FirebaseError = FirebaseError;
  21. function isBillingError(e) {
  22. var _a, _b, _c, _d;
  23. return !!((_d = (_c = (_b = (_a = e.context) === null || _a === void 0 ? void 0 : _a.body) === null || _b === void 0 ? void 0 : _b.error) === null || _c === void 0 ? void 0 : _c.details) === null || _d === void 0 ? void 0 : _d.find((d) => {
  24. var _a;
  25. return (((_a = d.violations) === null || _a === void 0 ? void 0 : _a.find((v) => v.type === "serviceusage/billing-enabled")) ||
  26. d.reason === "UREQ_PROJECT_BILLING_NOT_FOUND");
  27. }));
  28. }
  29. exports.isBillingError = isBillingError;