import { CombinedProtocolErrors } from "./CombinedProtocolErrors.js";
import { UnconventionalError } from "./UnconventionalError.js";
// 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).
export const PROTOCOL_ERRORS_SYMBOL = Symbol();
export function graphQLResultHasProtocolErrors(result) {
    if (result.extensions) {
        return (result.extensions[PROTOCOL_ERRORS_SYMBOL] instanceof 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"));
}
export function toErrorLike(error) {
    if (isErrorLike(error)) {
        return error;
    }
    if (typeof error === "string") {
        return new Error(error, { cause: error });
    }
    return new UnconventionalError(error);
}
export { CombinedGraphQLErrors } from "./CombinedGraphQLErrors.js";
export { CombinedProtocolErrors } from "./CombinedProtocolErrors.js";
export { ServerError } from "./ServerError.js";
export { ServerParseError } from "./ServerParseError.js";
export { UnconventionalError } from "./UnconventionalError.js";
//# sourceMappingURL=index.js.map
