@prismicio/custom-types-client
Version:
JavaScript client to interact with the Prismic Custom Types API
1 lines • 3.72 kB
Source Map (JSON)
{"version":3,"file":"errors.cjs","sources":["../../src/errors.ts"],"sourcesContent":["/**\n * Metadata about the failed Prismic Custom Types API request.\n */\ntype PrismicErrorArgs<TResponse> = {\n\t/**\n\t * The Prismic Custom Types API URL used for the failed request.\n\t */\n\turl: string;\n\n\t/**\n\t * The Prismic Custom Types API response from the failed request.\n\t */\n\tresponse?: TResponse;\n};\n\n/**\n * An error returned from the Prismic Custom Types API. It contains information\n * about the network request to aid in debugging.\n */\nexport class PrismicError<TResponse = never> extends Error {\n\t/**\n\t * The Prismic Custom Types API URL used for the failed request.\n\t */\n\turl: string;\n\n\t/**\n\t * The Prismic Custom Types API response from the failed request.\n\t */\n\tresponse?: TResponse;\n\n\t/**\n\t * Creates a new `PrismicError`.\n\t *\n\t * @param message - A description of the error.\n\t * @param args - Metadata about the failed network request.\n\t *\n\t * @returns A `PrismicError` for the given error state.\n\t */\n\tconstructor(message: string, args: PrismicErrorArgs<TResponse>) {\n\t\tsuper(message);\n\n\t\tthis.url = args.url;\n\t\tthis.response = args.response;\n\t}\n}\n\n/**\n * The response returned by the Prismic Custom Types API when forbidden.\n */\nexport interface ForbiddenErrorAPIResponse {\n\t/**\n\t * Description of the error.\n\t */\n\tmessage: string;\n}\n\n/**\n * The response returned by the Prismic Custom Types API bulk update transaction\n * endpoint when changes contain a deletion operation of custom type(s) with\n * existing document(s).\n */\ntype BulkUpdateHasExistingDocumentsErrorAPIResponse = {\n\t/**\n\t * Description of the error.\n\t */\n\tmessage: string;\n\n\t/**\n\t * Identify if the changes contain a deletion operation of custom type(s) with\n\t * existing document(s).\n\t */\n\thasExistingDocuments: true;\n};\n\n/**\n * Represents an error when the Prismic Custom Types API response is invalid.\n */\nexport class InvalidAPIResponse extends PrismicError {}\n\n/**\n * Represents an error when making an unauthorized Prismic Custom Types API\n * request.\n */\nexport class UnauthorizedError extends PrismicError<string> {}\n\n/**\n * Represents an error when making a forbidden Prismic Custom Types API request.\n */\nexport class ForbiddenError extends PrismicError<ForbiddenErrorAPIResponse> {}\n\n/**\n * Represents an error when an entity with the same ID already exists.\n */\nexport class ConflictError extends PrismicError {}\n\n/**\n * Represents an error when the requested entity could not be found.\n */\nexport class NotFoundError extends PrismicError {}\n\n/**\n * Represents an error when the provided data is invalid.\n */\nexport class InvalidPayloadError extends PrismicError<string> {}\n\n/**\n * Represents an error when a bulk update changes contain a deletion operation\n * of custom type(s) with existing document(s).\n */\nexport class BulkUpdateHasExistingDocumentsError extends PrismicError<BulkUpdateHasExistingDocumentsErrorAPIResponse> {}\n\n/**\n * Represents an error when a valid `fetch` function is not available to the\n * Prismic Custom Types API client.\n */\nexport class MissingFetchError extends Error {}\n"],"names":[],"mappings":";;;;;;;;AAmBM,MAAO,qBAAwC,MAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAmBzD,YAAY,SAAiB,MAAiC;AAC7D,UAAM,OAAO;AAhBd;AAAA;AAAA;AAAA;AAKA;AAAA;AAAA;AAAA;AAaC,SAAK,MAAM,KAAK;AAChB,SAAK,WAAW,KAAK;AAAA,EACtB;AACA;AAiCK,MAAO,2BAA2B,aAAY;AAAG;AAMjD,MAAO,0BAA0B,aAAoB;AAAG;AAKxD,MAAO,uBAAuB,aAAuC;AAAG;AAKxE,MAAO,sBAAsB,aAAY;AAAG;AAK5C,MAAO,sBAAsB,aAAY;AAAG;AAK5C,MAAO,4BAA4B,aAAoB;AAAG;AAM1D,MAAO,4CAA4C,aAA4D;AAAG;AAMlH,MAAO,0BAA0B,MAAK;AAAG;;;;;;;;;;"}