UNPKG

@aws-amplify/core

Version:

Core category of aws-amplify

1 lines • 2.23 kB
{"version":3,"file":"NoAmplifyContextError.mjs","sources":["../../../src/errors/NoAmplifyContextError.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AmplifyError } from './AmplifyError';\n/**\n * Stable error name/code thrown when a context is required but none is\n * available (i.e. `Amplify.configure()` has not been called and no context was\n * passed explicitly). Exposed as a constant so category packages can reliably\n * catch this failure by name without importing the class.\n */\nexport const NO_AMPLIFY_CONTEXT_ERROR_NAME = 'NoAmplifyContextError';\n/**\n * Thrown when a category API resolves the global {@link AmplifyContext} but none\n * has been set (the \"unconfigured\" path).\n *\n * Uses core's {@link AmplifyError} machinery so consumers can catch it via\n * `instanceof AmplifyError` / `instanceof NoAmplifyContextError`, or by the\n * stable `name` ({@link NO_AMPLIFY_CONTEXT_ERROR_NAME}).\n */\nexport class NoAmplifyContextError extends AmplifyError {\n constructor(message = 'No AmplifyContext available. Call Amplify.configure() to set a global context, ' +\n 'or pass a context as the first argument.') {\n super({\n name: NO_AMPLIFY_CONTEXT_ERROR_NAME,\n message,\n recoverySuggestion: 'Call Amplify.configure() before using this API, or pass an AmplifyContext ' +\n 'created via createAmplifyContext() as the first argument.',\n });\n // Hack for making the custom error class work when transpiled to es5.\n this.constructor = NoAmplifyContextError;\n Object.setPrototypeOf(this, NoAmplifyContextError.prototype);\n }\n}\n"],"names":[],"mappings":";;AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,6BAA6B,GAAG;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,qBAAqB,SAAS,YAAY,CAAC;AACxD,IAAI,WAAW,CAAC,OAAO,GAAG,iFAAiF;AAC3G,QAAQ,0CAA0C,EAAE;AACpD,QAAQ,KAAK,CAAC;AACd,YAAY,IAAI,EAAE,6BAA6B;AAC/C,YAAY,OAAO;AACnB,YAAY,kBAAkB,EAAE,4EAA4E;AAC5G,gBAAgB,2DAA2D;AAC3E,SAAS,CAAC;AACV;AACA,QAAQ,IAAI,CAAC,WAAW,GAAG,qBAAqB;AAChD,QAAQ,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,qBAAqB,CAAC,SAAS,CAAC;AACpE,IAAI;AACJ;;;;"}