@mysten/sui
Version:
Sui TypeScript API
1 lines • 2.34 kB
Source Map (JSON)
{"version":3,"file":"errors.mjs","names":[],"sources":["../../src/client/errors.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { ObjectResponseError } from '../jsonRpc/index.js';\nimport type { SuiClientTypes } from './types.js';\n\nexport class SuiClientError extends Error {}\n\nexport class SimulationError extends SuiClientError {\n\texecutionError?: SuiClientTypes.ExecutionError;\n\n\tconstructor(\n\t\tmessage: string,\n\t\toptions?: { cause?: unknown; executionError?: SuiClientTypes.ExecutionError },\n\t) {\n\t\tsuper(message, { cause: options?.cause });\n\t\tthis.executionError = options?.executionError;\n\t}\n}\n\nexport class ObjectError extends SuiClientError {\n\tcode: string;\n\n\tconstructor(code: string, message: string) {\n\t\tsuper(message);\n\t\tthis.code = code;\n\t}\n\n\tstatic fromResponse(response: ObjectResponseError, objectId?: string): ObjectError {\n\t\tswitch (response.code) {\n\t\t\tcase 'notExists':\n\t\t\t\treturn new ObjectError(response.code, `Object ${response.object_id} does not exist`);\n\t\t\tcase 'dynamicFieldNotFound':\n\t\t\t\treturn new ObjectError(\n\t\t\t\t\tresponse.code,\n\t\t\t\t\t`Dynamic field not found for object ${response.parent_object_id}`,\n\t\t\t\t);\n\t\t\tcase 'deleted':\n\t\t\t\treturn new ObjectError(response.code, `Object ${response.object_id} has been deleted`);\n\t\t\tcase 'displayError':\n\t\t\t\treturn new ObjectError(response.code, `Display error: ${response.error}`);\n\t\t\tcase 'unknown':\n\t\t\tdefault:\n\t\t\t\treturn new ObjectError(\n\t\t\t\t\tresponse.code,\n\t\t\t\t\t`Unknown error while loading object${objectId ? ` ${objectId}` : ''}`,\n\t\t\t\t);\n\t\t}\n\t}\n}\n"],"mappings":";AAMA,IAAa,iBAAb,cAAoC,MAAM;AAE1C,IAAa,kBAAb,cAAqC,eAAe;CAGnD,YACC,SACA,SACC;AACD,QAAM,SAAS,EAAE,OAAO,SAAS,OAAO,CAAC;AACzC,OAAK,iBAAiB,SAAS;;;AAIjC,IAAa,cAAb,MAAa,oBAAoB,eAAe;CAG/C,YAAY,MAAc,SAAiB;AAC1C,QAAM,QAAQ;AACd,OAAK,OAAO;;CAGb,OAAO,aAAa,UAA+B,UAAgC;AAClF,UAAQ,SAAS,MAAjB;GACC,KAAK,YACJ,QAAO,IAAI,YAAY,SAAS,MAAM,UAAU,SAAS,UAAU,iBAAiB;GACrF,KAAK,uBACJ,QAAO,IAAI,YACV,SAAS,MACT,sCAAsC,SAAS,mBAC/C;GACF,KAAK,UACJ,QAAO,IAAI,YAAY,SAAS,MAAM,UAAU,SAAS,UAAU,mBAAmB;GACvF,KAAK,eACJ,QAAO,IAAI,YAAY,SAAS,MAAM,kBAAkB,SAAS,QAAQ;GAC1E,KAAK;GACL,QACC,QAAO,IAAI,YACV,SAAS,MACT,qCAAqC,WAAW,IAAI,aAAa,KACjE"}