/**
 * Minified by jsDelivr using Terser v5.37.0.
 * Original file: /npm/apollo-server-errors@3.3.1/dist/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.formatApolloErrors=exports.UserInputError=exports.PersistedQueryNotSupportedError=exports.PersistedQueryNotFoundError=exports.ForbiddenError=exports.AuthenticationError=exports.ValidationError=exports.SyntaxError=exports.fromGraphQLError=exports.toApolloError=exports.ApolloError=void 0;const graphql_1=require("graphql");class ApolloError extends Error{constructor(r,e,o){if(super(r),this.name||Object.defineProperty(this,"name",{value:"ApolloError"}),null==o?void 0:o.extensions)throw Error("Pass extensions directly as the third argument of the ApolloError constructor: `new ApolloError(message, code, {myExt: value})`, not `new ApolloError(message, code, {extensions: {myExt: value}})`");this.extensions={...o,code:e}}toJSON(){return(0,graphql_1.formatError)(toGraphQLError(this))}toString(){return(0,graphql_1.printError)(toGraphQLError(this))}get[Symbol.toStringTag](){return this.name}}function toGraphQLError(r){return new graphql_1.GraphQLError(r.message,r.nodes,r.source,r.positions,r.path,r.originalError,r.extensions)}function enrichError(r,e=!1){var o,t,s;const n=Object.create(Object.getPrototypeOf(r),{name:{value:r.name},message:{value:r.message,enumerable:!0,writable:!0},locations:{value:r.locations||void 0,enumerable:!0},path:{value:r.path||void 0,enumerable:!0},nodes:{value:r.nodes||void 0},source:{value:r.source||void 0},positions:{value:r.positions||void 0},originalError:{value:r.originalError}});if(n.extensions={...r.extensions,code:(null===(o=r.extensions)||void 0===o?void 0:o.code)||"INTERNAL_SERVER_ERROR",exception:{...null===(t=r.extensions)||void 0===t?void 0:t.exception,...r.originalError}},delete n.extensions.exception.extensions,e&&!n.extensions.exception.stacktrace){const e=(null===(s=r.originalError)||void 0===s?void 0:s.stack)||r.stack;n.extensions.exception.stacktrace=null==e?void 0:e.split("\n")}return 0===Object.keys(n.extensions.exception).length&&delete n.extensions.exception,n}function toApolloError(r,e="INTERNAL_SERVER_ERROR"){let o=r;return o.extensions?o.extensions.code=e:o.extensions={code:e},o}function fromGraphQLError(r,e){const o=(null==e?void 0:e.errorClass)?new e.errorClass(r.message):new ApolloError(r.message);return Object.entries(r).forEach((([r,e])=>{"extensions"!==r&&(o[r]=e)})),o.extensions={...o.extensions,...r.extensions},o.extensions.code||(o.extensions.code=(null==e?void 0:e.code)||"INTERNAL_SERVER_ERROR"),Object.defineProperty(o,"originalError",{value:{}}),Object.getOwnPropertyNames(r).forEach((e=>{Object.defineProperty(o.originalError,e,{value:r[e]})})),o}exports.ApolloError=ApolloError,exports.toApolloError=toApolloError,exports.fromGraphQLError=fromGraphQLError;class SyntaxError extends ApolloError{constructor(r){super(r,"GRAPHQL_PARSE_FAILED"),Object.defineProperty(this,"name",{value:"SyntaxError"})}}exports.SyntaxError=SyntaxError;class ValidationError extends ApolloError{constructor(r){super(r,"GRAPHQL_VALIDATION_FAILED"),Object.defineProperty(this,"name",{value:"ValidationError"})}}exports.ValidationError=ValidationError;class AuthenticationError extends ApolloError{constructor(r,e){super(r,"UNAUTHENTICATED",e),Object.defineProperty(this,"name",{value:"AuthenticationError"})}}exports.AuthenticationError=AuthenticationError;class ForbiddenError extends ApolloError{constructor(r,e){super(r,"FORBIDDEN",e),Object.defineProperty(this,"name",{value:"ForbiddenError"})}}exports.ForbiddenError=ForbiddenError;class PersistedQueryNotFoundError extends ApolloError{constructor(){super("PersistedQueryNotFound","PERSISTED_QUERY_NOT_FOUND"),Object.defineProperty(this,"name",{value:"PersistedQueryNotFoundError"})}}exports.PersistedQueryNotFoundError=PersistedQueryNotFoundError;class PersistedQueryNotSupportedError extends ApolloError{constructor(){super("PersistedQueryNotSupported","PERSISTED_QUERY_NOT_SUPPORTED"),Object.defineProperty(this,"name",{value:"PersistedQueryNotSupportedError"})}}exports.PersistedQueryNotSupportedError=PersistedQueryNotSupportedError;class UserInputError extends ApolloError{constructor(r,e){super(r,"BAD_USER_INPUT",e),Object.defineProperty(this,"name",{value:"UserInputError"})}}function formatApolloErrors(r,e){if(!e)return r.map((r=>enrichError(r)));const{formatter:o,debug:t}=e,s=r.map((r=>enrichError(r,t)));return o?s.map((r=>{try{return(r=>{if(r instanceof Error){const e=r;return{message:e.message,...e.locations&&{locations:e.locations},...e.path&&{path:e.path},...e.extensions&&{extensions:e.extensions}}}return r})(o(r))}catch(r){if(t)return enrichError(r,t);return enrichError(fromGraphQLError(new graphql_1.GraphQLError("Internal server error")),t)}})):s}exports.UserInputError=UserInputError,exports.formatApolloErrors=formatApolloErrors;
//# sourceMappingURL=/sm/8fa5dfda536eaaf8ee275e6fc1ab155a355389e2f47077cf3abd7fb0a02703a9.map