mirror of
https://github.com/CamHenlin/MessagesForMacintosh.git
synced 2024-11-29 23:49:20 +00:00
45 lines
1.6 KiB
JavaScript
45 lines
1.6 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var tslib_1 = require("tslib");
|
|
var arrays_1 = require("../util/arrays");
|
|
function isApolloError(err) {
|
|
return err.hasOwnProperty('graphQLErrors');
|
|
}
|
|
exports.isApolloError = isApolloError;
|
|
var generateErrorMessage = function (err) {
|
|
var message = '';
|
|
if (arrays_1.isNonEmptyArray(err.graphQLErrors)) {
|
|
err.graphQLErrors.forEach(function (graphQLError) {
|
|
var errorMessage = graphQLError
|
|
? graphQLError.message
|
|
: 'Error message not found.';
|
|
message += "GraphQL error: " + errorMessage + "\n";
|
|
});
|
|
}
|
|
if (err.networkError) {
|
|
message += 'Network error: ' + err.networkError.message + '\n';
|
|
}
|
|
message = message.replace(/\n$/, '');
|
|
return message;
|
|
};
|
|
var ApolloError = (function (_super) {
|
|
tslib_1.__extends(ApolloError, _super);
|
|
function ApolloError(_a) {
|
|
var graphQLErrors = _a.graphQLErrors, networkError = _a.networkError, errorMessage = _a.errorMessage, extraInfo = _a.extraInfo;
|
|
var _this = _super.call(this, errorMessage) || this;
|
|
_this.graphQLErrors = graphQLErrors || [];
|
|
_this.networkError = networkError || null;
|
|
if (!errorMessage) {
|
|
_this.message = generateErrorMessage(_this);
|
|
}
|
|
else {
|
|
_this.message = errorMessage;
|
|
}
|
|
_this.extraInfo = extraInfo;
|
|
_this.__proto__ = ApolloError.prototype;
|
|
return _this;
|
|
}
|
|
return ApolloError;
|
|
}(Error));
|
|
exports.ApolloError = ApolloError;
|
|
//# sourceMappingURL=ApolloError.js.map
|