"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UnconventionalError = exports.ServerParseError = exports.ServerError = exports.CombinedProtocolErrors = exports.CombinedGraphQLErrors = exports.PROTOCOL_ERRORS_SYMBOL = void 0;
exports.graphQLResultHasProtocolErrors = graphQLResultHasProtocolErrors;
exports.toErrorLike = toErrorLike;
const CombinedProtocolErrors_js_1 = require("./CombinedProtocolErrors.cjs");
const UnconventionalError_js_1 = require("./UnconventionalError.cjs");
// This Symbol allows us to pass transport-specific errors from the link chain
// into QueryManager/client internals without risking a naming collision within
// extensions (which implementers can use as they see fit).
exports.PROTOCOL_ERRORS_SYMBOL = Symbol();
function graphQLResultHasProtocolErrors(result) {
    if (result.extensions) {
        return (result.extensions[exports.PROTOCOL_ERRORS_SYMBOL] instanceof CombinedProtocolErrors_js_1.CombinedProtocolErrors);
    }
    return false;
}
function isErrorLike(error) {
    return (error !== null &&
        typeof error === "object" &&
        typeof error.message === "string" &&
        typeof error.name === "string" &&
        (typeof error.stack === "string" ||
            typeof error.stack === "undefined"));
}
function toErrorLike(error) {
    if (isErrorLike(error)) {
        return error;
    }
    if (typeof error === "string") {
        return new Error(error, { cause: error });
    }
    return new UnconventionalError_js_1.UnconventionalError(error);
}
var CombinedGraphQLErrors_js_1 = require("./CombinedGraphQLErrors.cjs");
Object.defineProperty(exports, "CombinedGraphQLErrors", { enumerable: true, get: function () { return CombinedGraphQLErrors_js_1.CombinedGraphQLErrors; } });
var CombinedProtocolErrors_js_2 = require("./CombinedProtocolErrors.cjs");
Object.defineProperty(exports, "CombinedProtocolErrors", { enumerable: true, get: function () { return CombinedProtocolErrors_js_2.CombinedProtocolErrors; } });
var ServerError_js_1 = require("./ServerError.cjs");
Object.defineProperty(exports, "ServerError", { enumerable: true, get: function () { return ServerError_js_1.ServerError; } });
var ServerParseError_js_1 = require("./ServerParseError.cjs");
Object.defineProperty(exports, "ServerParseError", { enumerable: true, get: function () { return ServerParseError_js_1.ServerParseError; } });
var UnconventionalError_js_2 = require("./UnconventionalError.cjs");
Object.defineProperty(exports, "UnconventionalError", { enumerable: true, get: function () { return UnconventionalError_js_2.UnconventionalError; } });
//# sourceMappingURL=index.cjs.map
