fauna-gql-upload
Version:
Manage your FaunaDB resources in within your project and upload them using a single command
60 lines (59 loc) • 2.43 kB
JavaScript
;
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
exports.__esModule = true;
function displayErrors(err, type) {
var e_1, _a, e_2, _b;
if (err.requestResult) {
var response = JSON.parse(err.requestResult.responseRaw);
var errors_2 = response.errors;
console.group("Error uploading", type);
try {
for (var errors_1 = __values(errors_2), errors_1_1 = errors_1.next(); !errors_1_1.done; errors_1_1 = errors_1.next()) {
var error = errors_1_1.value;
var failures = error.failures;
console.log("".concat(error.code, ": ").concat(error.description));
if (failures) {
console.group("Failures");
try {
for (var failures_1 = (e_2 = void 0, __values(failures)), failures_1_1 = failures_1.next(); !failures_1_1.done; failures_1_1 = failures_1.next()) {
var fail_1 = failures_1_1.value;
console.log("".concat(fail_1.code, ": ").concat(fail_1.description));
console.log("field: ".concat(fail_1.field));
}
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (failures_1_1 && !failures_1_1.done && (_b = failures_1["return"])) _b.call(failures_1);
}
finally { if (e_2) throw e_2.error; }
}
console.groupEnd();
}
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (errors_1_1 && !errors_1_1.done && (_a = errors_1["return"])) _a.call(errors_1);
}
finally { if (e_1) throw e_1.error; }
}
console.groupEnd();
}
else {
throw err;
}
}
exports["default"] = displayErrors;
;