@metamask-previews/snap-networks-utils 1.0.0-preview-0a84cd9 → 1.0.0-preview-5f4fa3b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -0
- package/dist/index.cjs +5 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/utils/errors/index.cjs +7 -1
- package/dist/utils/errors/index.cjs.map +1 -1
- package/dist/utils/errors/index.d.cts +3 -0
- package/dist/utils/errors/index.d.cts.map +1 -1
- package/dist/utils/errors/index.d.mts +3 -0
- package/dist/utils/errors/index.d.mts.map +1 -1
- package/dist/utils/errors/index.mjs +2 -0
- package/dist/utils/errors/index.mjs.map +1 -1
- package/dist/utils/errors/stringifyReason.cjs +36 -0
- package/dist/utils/errors/stringifyReason.cjs.map +1 -0
- package/dist/utils/errors/stringifyReason.d.cts +15 -0
- package/dist/utils/errors/stringifyReason.d.cts.map +1 -0
- package/dist/utils/errors/stringifyReason.d.mts +15 -0
- package/dist/utils/errors/stringifyReason.d.mts.map +1 -0
- package/dist/utils/errors/stringifyReason.mjs +33 -0
- package/dist/utils/errors/stringifyReason.mjs.map +1 -0
- package/dist/utils/errors/syncError.cjs +98 -0
- package/dist/utils/errors/syncError.cjs.map +1 -0
- package/dist/utils/errors/syncError.d.cts +60 -0
- package/dist/utils/errors/syncError.d.cts.map +1 -0
- package/dist/utils/errors/syncError.d.mts +60 -0
- package/dist/utils/errors/syncError.d.mts.map +1 -0
- package/dist/utils/errors/syncError.mjs +92 -0
- package/dist/utils/errors/syncError.mjs.map +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
9
9
|
|
|
10
10
|
### Added
|
|
11
11
|
|
|
12
|
+
- Add `SynchronizationError`, `formatAccountSyncFailures`, and the `AccountSyncFailure` type, for reporting account synchronization failures with per-account failure details embedded in the error message (details must live in the message because `snap_trackError` only serializes `name`, `message`, `stack`, and `cause`). ([#374](https://github.com/MetaMask/internal-snaps/pull/374))
|
|
12
13
|
- Add `wrapSnapHandlers` to wrap any Snap entrypoint handlers with `withCatchAndThrowSnapError`, with optional per-handler `logError` overrides ([#341](https://github.com/MetaMask/internal-snaps/pull/341))
|
|
13
14
|
- Add `noopAssetHandlers`, the no-op asset entrypoints network Snaps must export to keep the `endowment:assets` permission ([#341](https://github.com/MetaMask/internal-snaps/pull/341))
|
|
14
15
|
- Add a shared `AnalyticsService` and typed event properties for network Snap telemetry. ([#327](https://github.com/MetaMask/internal-snaps/pull/327))
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createSnapErrorHandling = exports.InMemoryState = exports.State = exports.validateOrigin = exports.DEFAULT_METAMASK_ORIGIN = exports.DEFAULT_DEV_ORIGINS = exports.DEFAULT_PROD_ORIGINS = exports.createOriginPermissions = exports.PROOF_OF_OWNERSHIP_MESSAGE_PREFIX = exports.ProofOfOwnershipMessageStruct = exports.ProofOfOwnershipBatchSuccessStruct = exports.ProofOfOwnershipBatchResponseStruct = exports.ProofOfOwnershipBatchRequestParamsStruct = exports.ProofOfOwnershipBatchRequestItemStruct = exports.ProofOfOwnershipBatchItemResponseStruct = exports.ProofOfOwnershipBatchErrorStruct = exports.parseProofOfOwnershipMessage = exports.deserialize = exports.serialize = exports.LogLevel = exports.Logger = exports.chunks = exports.batchesAllWithChunks = exports.batchesAllSettledWithChunks = exports.batchesAllSettled = exports.batchesAll = exports.EnvironmentStruct = exports.Environment = exports.LogLevelStruct = exports.parseFloatStruct = exports.parseIntegerStruct = exports.emptyToUndefined = exports.defaultedUrlStruct = exports.commaSeparatedListOf = exports.BaseConfigProvider = exports.parseEnv = exports.asStrictKeyringAccount = exports.UuidStruct = exports.UrlStruct = exports.sanitizeUri = exports.sanitizeControlCharacters = exports.buildUrl = exports.safeMerge = exports.TransactionEventType = exports.SecurityEventType = exports.AnalyticsService = exports.RemoteFeatureFlagsProvider = exports.REMOTE_FEATURE_FLAGS_PROVIDER_NAME = exports.AssetsProvider = exports.ASSETS_PROVIDER_NAME = void 0;
|
|
4
|
-
exports.wrapSnapHandlers = exports.noopAssetHandlers = exports.useCacheUntil = exports.useCache = exports.StateCache = exports.InMemoryCache = exports.InFlightCoalescer = exports.normalizeError = exports.isSnapRpcError = exports.createWithCatchAndThrowSnapError = exports.createTrackError = void 0;
|
|
4
|
+
exports.wrapSnapHandlers = exports.noopAssetHandlers = exports.useCacheUntil = exports.useCache = exports.StateCache = exports.InMemoryCache = exports.InFlightCoalescer = exports.SynchronizationError = exports.stringifyReason = exports.normalizeError = exports.isSnapRpcError = exports.getSyncFailuresFromSettledResult = exports.formatAccountSyncFailures = exports.createWithCatchAndThrowSnapError = exports.createTrackError = void 0;
|
|
5
5
|
var AssetsProvider_1 = require("./providers/assets/AssetsProvider.cjs");
|
|
6
6
|
Object.defineProperty(exports, "ASSETS_PROVIDER_NAME", { enumerable: true, get: function () { return AssetsProvider_1.ASSETS_PROVIDER_NAME; } });
|
|
7
7
|
Object.defineProperty(exports, "AssetsProvider", { enumerable: true, get: function () { return AssetsProvider_1.AssetsProvider; } });
|
|
@@ -77,8 +77,12 @@ var errors_1 = require("./utils/errors/index.cjs");
|
|
|
77
77
|
Object.defineProperty(exports, "createSnapErrorHandling", { enumerable: true, get: function () { return errors_1.createSnapErrorHandling; } });
|
|
78
78
|
Object.defineProperty(exports, "createTrackError", { enumerable: true, get: function () { return errors_1.createTrackError; } });
|
|
79
79
|
Object.defineProperty(exports, "createWithCatchAndThrowSnapError", { enumerable: true, get: function () { return errors_1.createWithCatchAndThrowSnapError; } });
|
|
80
|
+
Object.defineProperty(exports, "formatAccountSyncFailures", { enumerable: true, get: function () { return errors_1.formatAccountSyncFailures; } });
|
|
81
|
+
Object.defineProperty(exports, "getSyncFailuresFromSettledResult", { enumerable: true, get: function () { return errors_1.getSyncFailuresFromSettledResult; } });
|
|
80
82
|
Object.defineProperty(exports, "isSnapRpcError", { enumerable: true, get: function () { return errors_1.isSnapRpcError; } });
|
|
81
83
|
Object.defineProperty(exports, "normalizeError", { enumerable: true, get: function () { return errors_1.normalizeError; } });
|
|
84
|
+
Object.defineProperty(exports, "stringifyReason", { enumerable: true, get: function () { return errors_1.stringifyReason; } });
|
|
85
|
+
Object.defineProperty(exports, "SynchronizationError", { enumerable: true, get: function () { return errors_1.SynchronizationError; } });
|
|
82
86
|
var InFlightCoalescer_1 = require("./utils/dedupe/InFlightCoalescer.cjs");
|
|
83
87
|
Object.defineProperty(exports, "InFlightCoalescer", { enumerable: true, get: function () { return InFlightCoalescer_1.InFlightCoalescer; } });
|
|
84
88
|
var InMemoryCache_1 = require("./utils/cache/InMemoryCache.cjs");
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,wEAI2C;AAHzC,sHAAA,oBAAoB,OAAA;AACpB,gHAAA,cAAc,OAAA;AAGhB,8GAIqE;AAHnE,gJAAA,kCAAkC,OAAA;AAClC,wIAAA,0BAA0B,OAAA;AAG5B,8EAI+C;AAH7C,oHAAA,gBAAgB,OAAA;AAChB,qHAAA,iBAAiB,OAAA;AACjB,wHAAA,oBAAoB,OAAA;AAYtB,6DAAwD;AAA/C,sGAAA,SAAS,OAAA;AAClB,0DAAqD;AAA5C,oGAAA,QAAQ,OAAA;AAEjB,0DAGmC;AAFjC,qHAAA,yBAAyB,OAAA;AACzB,uGAAA,WAAW,OAAA;AAEb,6DAAwD;AAA/C,sGAAA,SAAS,OAAA;AAClB,gEAA2D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FAUmD;AATjD,gIAAA,4BAA4B,OAAA;AAC5B,oIAAA,gCAAgC,OAAA;AAChC,2IAAA,uCAAuC,OAAA;AACvC,0IAAA,sCAAsC,OAAA;AACtC,4IAAA,wCAAwC,OAAA;AACxC,uIAAA,mCAAmC,OAAA;AACnC,sIAAA,kCAAkC,OAAA;AAClC,iIAAA,6BAA6B,OAAA;AAC7B,qIAAA,iCAAiC,OAAA;AAWnC,iGAK2D;AAJzD,kIAAA,uBAAuB,OAAA;AACvB,+HAAA,oBAAoB,OAAA;AACpB,8HAAA,mBAAmB,OAAA;AACnB,kIAAA,uBAAuB,OAAA;AAGzB,+EAA0E;AAAjE,gHAAA,cAAc,OAAA;AACvB,iDAA4C;AAAnC,8FAAA,KAAK,OAAA;AAEd,iEAA4D;AAAnD,8GAAA,aAAa,OAAA;AAEtB,mDAUwB;AATtB,iHAAA,uBAAuB,OAAA;AACvB,0GAAA,gBAAgB,OAAA;AAChB,0HAAA,gCAAgC,OAAA;AAChC,mHAAA,yBAAyB,OAAA;AACzB,0HAAA,gCAAgC,OAAA;AAChC,wGAAA,cAAc,OAAA;AACd,wGAAA,cAAc,OAAA;AACd,yGAAA,eAAe,OAAA;AACf,8GAAA,oBAAoB,OAAA;AAEtB,0EAAqE;AAA5D,sHAAA,iBAAiB,OAAA;AAC1B,iEAA4D;AAAnD,8GAAA,aAAa,OAAA;AACtB,2DAAsD;AAA7C,wGAAA,UAAU,OAAA;AACnB,uDAAkD;AAAzC,oGAAA,QAAQ,OAAA;AACjB,iEAA4D;AAAnD,8GAAA,aAAa,OAAA;AAiBtB,0EAG2C;AAFzC,qHAAA,iBAAiB,OAAA;AACjB,oHAAA,gBAAgB,OAAA","sourcesContent":["export {\n ASSETS_PROVIDER_NAME,\n AssetsProvider,\n type AssetsProviderMessenger,\n} from './providers/assets/AssetsProvider';\nexport {\n REMOTE_FEATURE_FLAGS_PROVIDER_NAME,\n RemoteFeatureFlagsProvider,\n type RemoteFeatureFlagsProviderMessenger,\n} from './providers/remote-feature-flags/RemoteFeatureFlagsProvider';\nexport {\n AnalyticsService,\n SecurityEventType,\n TransactionEventType,\n} from './services/analytics/AnalyticsService';\nexport type {\n AnalyticsServiceOptions,\n SecurityAlertDetectedEventProperties,\n SecurityScanCompletedEventProperties,\n SnapTrackEventRequest,\n TrackEventCapableProvider,\n TransactionEventProperties,\n TransactionFinalizedEventProperties,\n WebSocketConnectionClosedEventProperties,\n} from './services/analytics/AnalyticsService';\nexport { safeMerge } from './utils/safeMerge/safeMerge';\nexport { buildUrl } from './utils/buildUrl/buildUrl';\nexport type { BuildUrlParams } from './utils/buildUrl/buildUrl';\nexport {\n sanitizeControlCharacters,\n sanitizeUri,\n} from './utils/sanitize/sanitize';\nexport { UrlStruct } from './utils/urlStruct/urlStruct';\nexport { UuidStruct } from './utils/uuidStruct/uuidStruct';\nexport { asStrictKeyringAccount } from './utils/keyringAccount/keyringAccount';\nexport type {\n ExtendedKeyringAccount,\n KeyringAccountExtension,\n} from './utils/keyringAccount/keyringAccount';\nexport { parseEnv } from './utils/config/parseEnv';\nexport { BaseConfigProvider } from './utils/config/BaseConfigProvider';\nexport {\n commaSeparatedListOf,\n defaultedUrlStruct,\n emptyToUndefined,\n parseIntegerStruct,\n parseFloatStruct,\n} from './utils/config/envStructs';\nexport { LogLevelStruct } from './utils/config/logLevelStruct';\nexport {\n Environment,\n EnvironmentStruct,\n} from './utils/config/environmentStruct';\nexport {\n batchesAll,\n batchesAllSettled,\n batchesAllSettledWithChunks,\n batchesAllWithChunks,\n chunks,\n} from './utils/async/async';\nexport { Logger, LogLevel } from './utils/logger/Logger';\nexport type {\n LoggerOptions,\n LoggerMethod,\n LogMethod,\n LogMethodDecorator,\n LoggerDecorators,\n} from './utils/logger/Logger';\nexport { serialize, deserialize } from './utils/serialization/serialization';\nexport type { Serializable } from './utils/serialization/types';\nexport {\n parseProofOfOwnershipMessage,\n ProofOfOwnershipBatchErrorStruct,\n ProofOfOwnershipBatchItemResponseStruct,\n ProofOfOwnershipBatchRequestItemStruct,\n ProofOfOwnershipBatchRequestParamsStruct,\n ProofOfOwnershipBatchResponseStruct,\n ProofOfOwnershipBatchSuccessStruct,\n ProofOfOwnershipMessageStruct,\n PROOF_OF_OWNERSHIP_MESSAGE_PREFIX,\n} from './utils/proofOfOwnership/proofOfOwnership';\nexport type {\n ProofOfOwnershipBatchError,\n ProofOfOwnershipBatchItemResponse,\n ProofOfOwnershipBatchRequestItem,\n ProofOfOwnershipBatchRequestParams,\n ProofOfOwnershipBatchResponse,\n ProofOfOwnershipBatchSuccess,\n ProofOfOwnershipMessage,\n} from './utils/proofOfOwnership/proofOfOwnership';\nexport {\n createOriginPermissions,\n DEFAULT_PROD_ORIGINS,\n DEFAULT_DEV_ORIGINS,\n DEFAULT_METAMASK_ORIGIN,\n} from './utils/originPermissions/createOriginPermissions';\nexport type { CreateOriginPermissionsParams } from './utils/originPermissions/createOriginPermissions';\nexport { validateOrigin } from './utils/originPermissions/validateOrigin';\nexport { State } from './utils/state/State';\nexport type { StateConfig } from './utils/state/State';\nexport { InMemoryState } from './utils/state/InMemoryState';\nexport type { IStateManager } from './utils/state/IStateManager';\nexport {\n createSnapErrorHandling,\n createTrackError,\n createWithCatchAndThrowSnapError,\n formatAccountSyncFailures,\n getSyncFailuresFromSettledResult,\n isSnapRpcError,\n normalizeError,\n stringifyReason,\n SynchronizationError,\n} from './utils/errors';\nexport { InFlightCoalescer } from './utils/dedupe/InFlightCoalescer';\nexport { InMemoryCache } from './utils/cache/InMemoryCache';\nexport { StateCache } from './utils/cache/StateCache';\nexport { useCache } from './utils/cache/useCache';\nexport { useCacheUntil } from './utils/cache/useCacheUntil';\nexport type { CacheOptions } from './utils/cache/useCache';\nexport type {\n CacheUntilOptions,\n ResultWithExpiry,\n} from './utils/cache/useCacheUntil';\nexport type {\n ICache,\n CacheEntry,\n TimestampMilliseconds,\n} from './utils/cache/types';\nexport type {\n CacheStateManager,\n CacheStore,\n CachePrefix,\n StateValue,\n} from './utils/cache/StateCache';\nexport {\n noopAssetHandlers,\n wrapSnapHandlers,\n} from './utils/handlers/wrapSnapHandlers';\nexport type {\n SnapHandlers,\n WithCatchAndThrowSnapError,\n} from './utils/handlers/wrapSnapHandlers';\nexport type {\n AccountSyncFailure,\n CreateSnapErrorHandlingOptions,\n CreateTrackErrorOptions,\n CreateWithCatchAndThrowSnapErrorOptions,\n LogErrorFn,\n NormalizeErrorFn,\n PrepareErrorForTrackingFn,\n ShouldTrackErrorFn,\n SnapRpcError,\n SnapTrackErrorRequest,\n TrackErrorCapableProvider,\n TrackErrorFn,\n} from './utils/errors';\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -29,7 +29,7 @@ export { State } from "./utils/state/State.cjs";
|
|
|
29
29
|
export type { StateConfig } from "./utils/state/State.cjs";
|
|
30
30
|
export { InMemoryState } from "./utils/state/InMemoryState.cjs";
|
|
31
31
|
export type { IStateManager } from "./utils/state/IStateManager.cjs";
|
|
32
|
-
export { createSnapErrorHandling, createTrackError, createWithCatchAndThrowSnapError, isSnapRpcError, normalizeError, } from "./utils/errors/index.cjs";
|
|
32
|
+
export { createSnapErrorHandling, createTrackError, createWithCatchAndThrowSnapError, formatAccountSyncFailures, getSyncFailuresFromSettledResult, isSnapRpcError, normalizeError, stringifyReason, SynchronizationError, } from "./utils/errors/index.cjs";
|
|
33
33
|
export { InFlightCoalescer } from "./utils/dedupe/InFlightCoalescer.cjs";
|
|
34
34
|
export { InMemoryCache } from "./utils/cache/InMemoryCache.cjs";
|
|
35
35
|
export { StateCache } from "./utils/cache/StateCache.cjs";
|
|
@@ -41,5 +41,5 @@ export type { ICache, CacheEntry, TimestampMilliseconds, } from "./utils/cache/t
|
|
|
41
41
|
export type { CacheStateManager, CacheStore, CachePrefix, StateValue, } from "./utils/cache/StateCache.cjs";
|
|
42
42
|
export { noopAssetHandlers, wrapSnapHandlers, } from "./utils/handlers/wrapSnapHandlers.cjs";
|
|
43
43
|
export type { SnapHandlers, WithCatchAndThrowSnapError, } from "./utils/handlers/wrapSnapHandlers.cjs";
|
|
44
|
-
export type { CreateSnapErrorHandlingOptions, CreateTrackErrorOptions, CreateWithCatchAndThrowSnapErrorOptions, LogErrorFn, NormalizeErrorFn, PrepareErrorForTrackingFn, ShouldTrackErrorFn, SnapRpcError, SnapTrackErrorRequest, TrackErrorCapableProvider, TrackErrorFn, } from "./utils/errors/index.cjs";
|
|
44
|
+
export type { AccountSyncFailure, CreateSnapErrorHandlingOptions, CreateTrackErrorOptions, CreateWithCatchAndThrowSnapErrorOptions, LogErrorFn, NormalizeErrorFn, PrepareErrorForTrackingFn, ShouldTrackErrorFn, SnapRpcError, SnapTrackErrorRequest, TrackErrorCapableProvider, TrackErrorFn, } from "./utils/errors/index.cjs";
|
|
45
45
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,KAAK,uBAAuB,GAC7B,8CAA0C;AAC3C,OAAO,EACL,kCAAkC,EAClC,0BAA0B,EAC1B,KAAK,mCAAmC,GACzC,wEAAoE;AACrE,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,GACrB,kDAA8C;AAC/C,YAAY,EACV,uBAAuB,EACvB,oCAAoC,EACpC,oCAAoC,EACpC,qBAAqB,EACrB,yBAAyB,EACzB,0BAA0B,EAC1B,mCAAmC,EACnC,wCAAwC,GACzC,kDAA8C;AAC/C,OAAO,EAAE,SAAS,EAAE,wCAAoC;AACxD,OAAO,EAAE,QAAQ,EAAE,sCAAkC;AACrD,YAAY,EAAE,cAAc,EAAE,sCAAkC;AAChE,OAAO,EACL,yBAAyB,EACzB,WAAW,GACZ,sCAAkC;AACnC,OAAO,EAAE,SAAS,EAAE,wCAAoC;AACxD,OAAO,EAAE,UAAU,EAAE,0CAAsC;AAC3D,OAAO,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AAY,EAAE,YAAY,EAAE,mCAA+B;AAC3D,YAAY,EACV,iBAAiB,EACjB,gBAAgB,GACjB,wCAAoC;AACrC,YAAY,EACV,MAAM,EACN,UAAU,EACV,qBAAqB,GACtB,gCAA4B;AAC7B,YAAY,EACV,iBAAiB,EACjB,UAAU,EACV,WAAW,EACX,UAAU,GACX,qCAAiC;AAClC,OAAO,EACL,iBAAiB,EACjB,gBAAgB,GACjB,8CAA0C;AAC3C,YAAY,EACV,YAAY,EACZ,0BAA0B,GAC3B,8CAA0C;AAC3C,YAAY,EACV,kBAAkB,EAClB,8BAA8B,EAC9B,uBAAuB,EACvB,uCAAuC,EACvC,UAAU,EACV,gBAAgB,EAChB,yBAAyB,EACzB,kBAAkB,EAClB,YAAY,EACZ,qBAAqB,EACrB,yBAAyB,EACzB,YAAY,GACb,iCAAuB"}
|
package/dist/index.d.mts
CHANGED
|
@@ -29,7 +29,7 @@ export { State } from "./utils/state/State.mjs";
|
|
|
29
29
|
export type { StateConfig } from "./utils/state/State.mjs";
|
|
30
30
|
export { InMemoryState } from "./utils/state/InMemoryState.mjs";
|
|
31
31
|
export type { IStateManager } from "./utils/state/IStateManager.mjs";
|
|
32
|
-
export { createSnapErrorHandling, createTrackError, createWithCatchAndThrowSnapError, isSnapRpcError, normalizeError, } from "./utils/errors/index.mjs";
|
|
32
|
+
export { createSnapErrorHandling, createTrackError, createWithCatchAndThrowSnapError, formatAccountSyncFailures, getSyncFailuresFromSettledResult, isSnapRpcError, normalizeError, stringifyReason, SynchronizationError, } from "./utils/errors/index.mjs";
|
|
33
33
|
export { InFlightCoalescer } from "./utils/dedupe/InFlightCoalescer.mjs";
|
|
34
34
|
export { InMemoryCache } from "./utils/cache/InMemoryCache.mjs";
|
|
35
35
|
export { StateCache } from "./utils/cache/StateCache.mjs";
|
|
@@ -41,5 +41,5 @@ export type { ICache, CacheEntry, TimestampMilliseconds, } from "./utils/cache/t
|
|
|
41
41
|
export type { CacheStateManager, CacheStore, CachePrefix, StateValue, } from "./utils/cache/StateCache.mjs";
|
|
42
42
|
export { noopAssetHandlers, wrapSnapHandlers, } from "./utils/handlers/wrapSnapHandlers.mjs";
|
|
43
43
|
export type { SnapHandlers, WithCatchAndThrowSnapError, } from "./utils/handlers/wrapSnapHandlers.mjs";
|
|
44
|
-
export type { CreateSnapErrorHandlingOptions, CreateTrackErrorOptions, CreateWithCatchAndThrowSnapErrorOptions, LogErrorFn, NormalizeErrorFn, PrepareErrorForTrackingFn, ShouldTrackErrorFn, SnapRpcError, SnapTrackErrorRequest, TrackErrorCapableProvider, TrackErrorFn, } from "./utils/errors/index.mjs";
|
|
44
|
+
export type { AccountSyncFailure, CreateSnapErrorHandlingOptions, CreateTrackErrorOptions, CreateWithCatchAndThrowSnapErrorOptions, LogErrorFn, NormalizeErrorFn, PrepareErrorForTrackingFn, ShouldTrackErrorFn, SnapRpcError, SnapTrackErrorRequest, TrackErrorCapableProvider, TrackErrorFn, } from "./utils/errors/index.mjs";
|
|
45
45
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,KAAK,uBAAuB,GAC7B,8CAA0C;AAC3C,OAAO,EACL,kCAAkC,EAClC,0BAA0B,EAC1B,KAAK,mCAAmC,GACzC,wEAAoE;AACrE,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,GACrB,kDAA8C;AAC/C,YAAY,EACV,uBAAuB,EACvB,oCAAoC,EACpC,oCAAoC,EACpC,qBAAqB,EACrB,yBAAyB,EACzB,0BAA0B,EAC1B,mCAAmC,EACnC,wCAAwC,GACzC,kDAA8C;AAC/C,OAAO,EAAE,SAAS,EAAE,wCAAoC;AACxD,OAAO,EAAE,QAAQ,EAAE,sCAAkC;AACrD,YAAY,EAAE,cAAc,EAAE,sCAA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AAa,EAAE,wCAAoC;AAC5D,OAAO,EAAE,UAAU,EAAE,qCAAiC;AACtD,OAAO,EAAE,QAAQ,EAAE,mCAA+B;AAClD,OAAO,EAAE,aAAa,EAAE,wCAAoC;AAC5D,YAAY,EAAE,YAAY,EAAE,mCAA+B;AAC3D,YAAY,EACV,iBAAiB,EACjB,gBAAgB,GACjB,wCAAoC;AACrC,YAAY,EACV,MAAM,EACN,UAAU,EACV,qBAAqB,GACtB,gCAA4B;AAC7B,YAAY,EACV,iBAAiB,EACjB,UAAU,EACV,WAAW,EACX,UAAU,GACX,qCAAiC;AAClC,OAAO,EACL,iBAAiB,EACjB,gBAAgB,GACjB,8CAA0C;AAC3C,YAAY,EACV,YAAY,EACZ,0BAA0B,GAC3B,8CAA0C;AAC3C,YAAY,EACV,kBAAkB,EAClB,8BAA8B,EAC9B,uBAAuB,EACvB,uCAAuC,EACvC,UAAU,EACV,gBAAgB,EAChB,yBAAyB,EACzB,kBAAkB,EAClB,YAAY,EACZ,qBAAqB,EACrB,yBAAyB,EACzB,YAAY,GACb,iCAAuB"}
|
package/dist/index.mjs
CHANGED
|
@@ -20,7 +20,7 @@ export { createOriginPermissions, DEFAULT_PROD_ORIGINS, DEFAULT_DEV_ORIGINS, DEF
|
|
|
20
20
|
export { validateOrigin } from "./utils/originPermissions/validateOrigin.mjs";
|
|
21
21
|
export { State } from "./utils/state/State.mjs";
|
|
22
22
|
export { InMemoryState } from "./utils/state/InMemoryState.mjs";
|
|
23
|
-
export { createSnapErrorHandling, createTrackError, createWithCatchAndThrowSnapError, isSnapRpcError, normalizeError } from "./utils/errors/index.mjs";
|
|
23
|
+
export { createSnapErrorHandling, createTrackError, createWithCatchAndThrowSnapError, formatAccountSyncFailures, getSyncFailuresFromSettledResult, isSnapRpcError, normalizeError, stringifyReason, SynchronizationError } from "./utils/errors/index.mjs";
|
|
24
24
|
export { InFlightCoalescer } from "./utils/dedupe/InFlightCoalescer.mjs";
|
|
25
25
|
export { InMemoryCache } from "./utils/cache/InMemoryCache.mjs";
|
|
26
26
|
export { StateCache } from "./utils/cache/StateCache.mjs";
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,cAAc,EAEf,8CAA0C;AAC3C,OAAO,EACL,kCAAkC,EAClC,0BAA0B,EAE3B,wEAAoE;AACrE,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EACrB,kDAA8C;AAW/C,OAAO,EAAE,SAAS,EAAE,wCAAoC;AACxD,OAAO,EAAE,QAAQ,EAAE,sCAAkC;AAErD,OAAO,EACL,yBAAyB,EACzB,WAAW,EACZ,sCAAkC;AACnC,OAAO,EAAE,SAAS,EAAE,wCAAoC;AACxD,OAAO,EAAE,UAAU,EAAE,0CAAsC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,kDAA8C;AAK/E,OAAO,EAAE,QAAQ,EAAE,oCAAgC;AACnD,OAAO,EAAE,kBAAkB,EAAE,8CAA0C;AACvE,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EACjB,sCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,0CAAsC;AAC/D,OAAO,EACL,WAAW,EACX,iBAAiB,EAClB,6CAAyC;AAC1C,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,2BAA2B,EAC3B,oBAAoB,EACpB,MAAM,EACP,gCAA4B;AAC7B,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,kCAA8B;AAQzD,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,gDAA4C;AAE7E,OAAO,EACL,4BAA4B,EAC5B,gCAAgC,EAChC,uCAAuC,EACvC,sCAAsC,EACtC,wCAAwC,EACxC,mCAAmC,EACnC,kCAAkC,EAClC,6BAA6B,EAC7B,iCAAiC,EAClC,sDAAkD;AAUnD,OAAO,EACL,uBAAuB,EACvB,oBAAoB,EACpB,mBAAmB,EACnB,uBAAuB,EACxB,8DAA0D;AAE3D,OAAO,EAAE,cAAc,EAAE,qDAAiD;AAC1E,OAAO,EAAE,KAAK,EAAE,gCAA4B;AAE5C,OAAO,EAAE,aAAa,EAAE,wCAAoC;AAE5D,OAAO,EACL,uBAAuB,EACvB,gBAAgB,EAChB,gCAAgC,EAChC,cAAc,EACd,cAAc,EACf,iCAAuB;AACxB,OAAO,EAAE,iBAAiB,EAAE,6CAAyC;AACrE,OAAO,EAAE,aAAa,EAAE,wCAAoC;AAC5D,OAAO,EAAE,UAAU,EAAE,qCAAiC;AACtD,OAAO,EAAE,QAAQ,EAAE,mCAA+B;AAClD,OAAO,EAAE,aAAa,EAAE,wCAAoC;AAiB5D,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EACjB,8CAA0C","sourcesContent":["export {\n ASSETS_PROVIDER_NAME,\n AssetsProvider,\n type AssetsProviderMessenger,\n} from './providers/assets/AssetsProvider';\nexport {\n REMOTE_FEATURE_FLAGS_PROVIDER_NAME,\n RemoteFeatureFlagsProvider,\n type RemoteFeatureFlagsProviderMessenger,\n} from './providers/remote-feature-flags/RemoteFeatureFlagsProvider';\nexport {\n AnalyticsService,\n SecurityEventType,\n TransactionEventType,\n} from './services/analytics/AnalyticsService';\nexport type {\n AnalyticsServiceOptions,\n SecurityAlertDetectedEventProperties,\n SecurityScanCompletedEventProperties,\n SnapTrackEventRequest,\n TrackEventCapableProvider,\n TransactionEventProperties,\n TransactionFinalizedEventProperties,\n WebSocketConnectionClosedEventProperties,\n} from './services/analytics/AnalyticsService';\nexport { safeMerge } from './utils/safeMerge/safeMerge';\nexport { buildUrl } from './utils/buildUrl/buildUrl';\nexport type { BuildUrlParams } from './utils/buildUrl/buildUrl';\nexport {\n sanitizeControlCharacters,\n sanitizeUri,\n} from './utils/sanitize/sanitize';\nexport { UrlStruct } from './utils/urlStruct/urlStruct';\nexport { UuidStruct } from './utils/uuidStruct/uuidStruct';\nexport { asStrictKeyringAccount } from './utils/keyringAccount/keyringAccount';\nexport type {\n ExtendedKeyringAccount,\n KeyringAccountExtension,\n} from './utils/keyringAccount/keyringAccount';\nexport { parseEnv } from './utils/config/parseEnv';\nexport { BaseConfigProvider } from './utils/config/BaseConfigProvider';\nexport {\n commaSeparatedListOf,\n defaultedUrlStruct,\n emptyToUndefined,\n parseIntegerStruct,\n parseFloatStruct,\n} from './utils/config/envStructs';\nexport { LogLevelStruct } from './utils/config/logLevelStruct';\nexport {\n Environment,\n EnvironmentStruct,\n} from './utils/config/environmentStruct';\nexport {\n batchesAll,\n batchesAllSettled,\n batchesAllSettledWithChunks,\n batchesAllWithChunks,\n chunks,\n} from './utils/async/async';\nexport { Logger, LogLevel } from './utils/logger/Logger';\nexport type {\n LoggerOptions,\n LoggerMethod,\n LogMethod,\n LogMethodDecorator,\n LoggerDecorators,\n} from './utils/logger/Logger';\nexport { serialize, deserialize } from './utils/serialization/serialization';\nexport type { Serializable } from './utils/serialization/types';\nexport {\n parseProofOfOwnershipMessage,\n ProofOfOwnershipBatchErrorStruct,\n ProofOfOwnershipBatchItemResponseStruct,\n ProofOfOwnershipBatchRequestItemStruct,\n ProofOfOwnershipBatchRequestParamsStruct,\n ProofOfOwnershipBatchResponseStruct,\n ProofOfOwnershipBatchSuccessStruct,\n ProofOfOwnershipMessageStruct,\n PROOF_OF_OWNERSHIP_MESSAGE_PREFIX,\n} from './utils/proofOfOwnership/proofOfOwnership';\nexport type {\n ProofOfOwnershipBatchError,\n ProofOfOwnershipBatchItemResponse,\n ProofOfOwnershipBatchRequestItem,\n ProofOfOwnershipBatchRequestParams,\n ProofOfOwnershipBatchResponse,\n ProofOfOwnershipBatchSuccess,\n ProofOfOwnershipMessage,\n} from './utils/proofOfOwnership/proofOfOwnership';\nexport {\n createOriginPermissions,\n DEFAULT_PROD_ORIGINS,\n DEFAULT_DEV_ORIGINS,\n DEFAULT_METAMASK_ORIGIN,\n} from './utils/originPermissions/createOriginPermissions';\nexport type { CreateOriginPermissionsParams } from './utils/originPermissions/createOriginPermissions';\nexport { validateOrigin } from './utils/originPermissions/validateOrigin';\nexport { State } from './utils/state/State';\nexport type { StateConfig } from './utils/state/State';\nexport { InMemoryState } from './utils/state/InMemoryState';\nexport type { IStateManager } from './utils/state/IStateManager';\nexport {\n createSnapErrorHandling,\n createTrackError,\n createWithCatchAndThrowSnapError,\n isSnapRpcError,\n normalizeError,\n} from './utils/errors';\nexport { InFlightCoalescer } from './utils/dedupe/InFlightCoalescer';\nexport { InMemoryCache } from './utils/cache/InMemoryCache';\nexport { StateCache } from './utils/cache/StateCache';\nexport { useCache } from './utils/cache/useCache';\nexport { useCacheUntil } from './utils/cache/useCacheUntil';\nexport type { CacheOptions } from './utils/cache/useCache';\nexport type {\n CacheUntilOptions,\n ResultWithExpiry,\n} from './utils/cache/useCacheUntil';\nexport type {\n ICache,\n CacheEntry,\n TimestampMilliseconds,\n} from './utils/cache/types';\nexport type {\n CacheStateManager,\n CacheStore,\n CachePrefix,\n StateValue,\n} from './utils/cache/StateCache';\nexport {\n noopAssetHandlers,\n wrapSnapHandlers,\n} from './utils/handlers/wrapSnapHandlers';\nexport type {\n SnapHandlers,\n WithCatchAndThrowSnapError,\n} from './utils/handlers/wrapSnapHandlers';\nexport type {\n CreateSnapErrorHandlingOptions,\n CreateTrackErrorOptions,\n CreateWithCatchAndThrowSnapErrorOptions,\n LogErrorFn,\n NormalizeErrorFn,\n PrepareErrorForTrackingFn,\n ShouldTrackErrorFn,\n SnapRpcError,\n SnapTrackErrorRequest,\n TrackErrorCapableProvider,\n TrackErrorFn,\n} from './utils/errors';\n"]}
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,cAAc,EAEf,8CAA0C;AAC3C,OAAO,EACL,kCAAkC,EAClC,0BAA0B,EAE3B,wEAAoE;AACrE,OAAO,EACL,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cAAc,EACd,eAAe,EACf,oBAAoB,EACrB,iCAAuB;AACxB,OAAO,EAAE,iBAAiB,EAAE,6CAAyC;AACrE,OAAO,EAAE,aAAa,EAAE,wCAAoC;AAC5D,OAAO,EAAE,UAAU,EAAE,qCAAiC;AACtD,OAAO,EAAE,QAAQ,EAAE,mCAA+B;AAClD,OAAO,EAAE,aAAa,EAAE,wCAAoC;AAiB5D,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EACjB,8CAA0C","sourcesContent":["export {\n ASSETS_PROVIDER_NAME,\n AssetsProvider,\n type AssetsProviderMessenger,\n} from './providers/assets/AssetsProvider';\nexport {\n REMOTE_FEATURE_FLAGS_PROVIDER_NAME,\n RemoteFeatureFlagsProvider,\n type RemoteFeatureFlagsProviderMessenger,\n} from './providers/remote-feature-flags/RemoteFeatureFlagsProvider';\nexport {\n AnalyticsService,\n SecurityEventType,\n TransactionEventType,\n} from './services/analytics/AnalyticsService';\nexport type {\n AnalyticsServiceOptions,\n SecurityAlertDetectedEventProperties,\n SecurityScanCompletedEventProperties,\n SnapTrackEventRequest,\n TrackEventCapableProvider,\n TransactionEventProperties,\n TransactionFinalizedEventProperties,\n WebSocketConnectionClosedEventProperties,\n} from './services/analytics/AnalyticsService';\nexport { safeMerge } from './utils/safeMerge/safeMerge';\nexport { buildUrl } from './utils/buildUrl/buildUrl';\nexport type { BuildUrlParams } from './utils/buildUrl/buildUrl';\nexport {\n sanitizeControlCharacters,\n sanitizeUri,\n} from './utils/sanitize/sanitize';\nexport { UrlStruct } from './utils/urlStruct/urlStruct';\nexport { UuidStruct } from './utils/uuidStruct/uuidStruct';\nexport { asStrictKeyringAccount } from './utils/keyringAccount/keyringAccount';\nexport type {\n ExtendedKeyringAccount,\n KeyringAccountExtension,\n} from './utils/keyringAccount/keyringAccount';\nexport { parseEnv } from './utils/config/parseEnv';\nexport { BaseConfigProvider } from './utils/config/BaseConfigProvider';\nexport {\n commaSeparatedListOf,\n defaultedUrlStruct,\n emptyToUndefined,\n parseIntegerStruct,\n parseFloatStruct,\n} from './utils/config/envStructs';\nexport { LogLevelStruct } from './utils/config/logLevelStruct';\nexport {\n Environment,\n EnvironmentStruct,\n} from './utils/config/environmentStruct';\nexport {\n batchesAll,\n batchesAllSettled,\n batchesAllSettledWithChunks,\n batchesAllWithChunks,\n chunks,\n} from './utils/async/async';\nexport { Logger, LogLevel } from './utils/logger/Logger';\nexport type {\n LoggerOptions,\n LoggerMethod,\n LogMethod,\n LogMethodDecorator,\n LoggerDecorators,\n} from './utils/logger/Logger';\nexport { serialize, deserialize } from './utils/serialization/serialization';\nexport type { Serializable } from './utils/serialization/types';\nexport {\n parseProofOfOwnershipMessage,\n ProofOfOwnershipBatchErrorStruct,\n ProofOfOwnershipBatchItemResponseStruct,\n ProofOfOwnershipBatchRequestItemStruct,\n ProofOfOwnershipBatchRequestParamsStruct,\n ProofOfOwnershipBatchResponseStruct,\n ProofOfOwnershipBatchSuccessStruct,\n ProofOfOwnershipMessageStruct,\n PROOF_OF_OWNERSHIP_MESSAGE_PREFIX,\n} from './utils/proofOfOwnership/proofOfOwnership';\nexport type {\n ProofOfOwnershipBatchError,\n ProofOfOwnershipBatchItemResponse,\n ProofOfOwnershipBatchRequestItem,\n ProofOfOwnershipBatchRequestParams,\n ProofOfOwnershipBatchResponse,\n ProofOfOwnershipBatchSuccess,\n ProofOfOwnershipMessage,\n} from './utils/proofOfOwnership/proofOfOwnership';\nexport {\n createOriginPermissions,\n DEFAULT_PROD_ORIGINS,\n DEFAULT_DEV_ORIGINS,\n DEFAULT_METAMASK_ORIGIN,\n} from './utils/originPermissions/createOriginPermissions';\nexport type { CreateOriginPermissionsParams } from './utils/originPermissions/createOriginPermissions';\nexport { validateOrigin } from './utils/originPermissions/validateOrigin';\nexport { State } from './utils/state/State';\nexport type { StateConfig } from './utils/state/State';\nexport { InMemoryState } from './utils/state/InMemoryState';\nexport type { IStateManager } from './utils/state/IStateManager';\nexport {\n createSnapErrorHandling,\n createTrackError,\n createWithCatchAndThrowSnapError,\n formatAccountSyncFailures,\n getSyncFailuresFromSettledResult,\n isSnapRpcError,\n normalizeError,\n stringifyReason,\n SynchronizationError,\n} from './utils/errors';\nexport { InFlightCoalescer } from './utils/dedupe/InFlightCoalescer';\nexport { InMemoryCache } from './utils/cache/InMemoryCache';\nexport { StateCache } from './utils/cache/StateCache';\nexport { useCache } from './utils/cache/useCache';\nexport { useCacheUntil } from './utils/cache/useCacheUntil';\nexport type { CacheOptions } from './utils/cache/useCache';\nexport type {\n CacheUntilOptions,\n ResultWithExpiry,\n} from './utils/cache/useCacheUntil';\nexport type {\n ICache,\n CacheEntry,\n TimestampMilliseconds,\n} from './utils/cache/types';\nexport type {\n CacheStateManager,\n CacheStore,\n CachePrefix,\n StateValue,\n} from './utils/cache/StateCache';\nexport {\n noopAssetHandlers,\n wrapSnapHandlers,\n} from './utils/handlers/wrapSnapHandlers';\nexport type {\n SnapHandlers,\n WithCatchAndThrowSnapError,\n} from './utils/handlers/wrapSnapHandlers';\nexport type {\n AccountSyncFailure,\n CreateSnapErrorHandlingOptions,\n CreateTrackErrorOptions,\n CreateWithCatchAndThrowSnapErrorOptions,\n LogErrorFn,\n NormalizeErrorFn,\n PrepareErrorForTrackingFn,\n ShouldTrackErrorFn,\n SnapRpcError,\n SnapTrackErrorRequest,\n TrackErrorCapableProvider,\n TrackErrorFn,\n} from './utils/errors';\n"]}
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isSnapRpcError = exports.normalizeError = exports.createWithCatchAndThrowSnapError = exports.createTrackError = exports.createSnapErrorHandling = void 0;
|
|
3
|
+
exports.isSnapRpcError = exports.stringifyReason = exports.normalizeError = exports.createWithCatchAndThrowSnapError = exports.getSyncFailuresFromSettledResult = exports.formatAccountSyncFailures = exports.SynchronizationError = exports.createTrackError = exports.createSnapErrorHandling = void 0;
|
|
4
4
|
var trackError_1 = require("./trackError.cjs");
|
|
5
5
|
Object.defineProperty(exports, "createSnapErrorHandling", { enumerable: true, get: function () { return trackError_1.createSnapErrorHandling; } });
|
|
6
6
|
Object.defineProperty(exports, "createTrackError", { enumerable: true, get: function () { return trackError_1.createTrackError; } });
|
|
7
|
+
var syncError_1 = require("./syncError.cjs");
|
|
8
|
+
Object.defineProperty(exports, "SynchronizationError", { enumerable: true, get: function () { return syncError_1.SynchronizationError; } });
|
|
9
|
+
Object.defineProperty(exports, "formatAccountSyncFailures", { enumerable: true, get: function () { return syncError_1.formatAccountSyncFailures; } });
|
|
10
|
+
Object.defineProperty(exports, "getSyncFailuresFromSettledResult", { enumerable: true, get: function () { return syncError_1.getSyncFailuresFromSettledResult; } });
|
|
7
11
|
var errors_1 = require("./errors.cjs");
|
|
8
12
|
Object.defineProperty(exports, "createWithCatchAndThrowSnapError", { enumerable: true, get: function () { return errors_1.createWithCatchAndThrowSnapError; } });
|
|
9
13
|
Object.defineProperty(exports, "normalizeError", { enumerable: true, get: function () { return errors_1.normalizeError; } });
|
|
14
|
+
var stringifyReason_1 = require("./stringifyReason.cjs");
|
|
15
|
+
Object.defineProperty(exports, "stringifyReason", { enumerable: true, get: function () { return stringifyReason_1.stringifyReason; } });
|
|
10
16
|
var snapRpcError_1 = require("./snapRpcError.cjs");
|
|
11
17
|
Object.defineProperty(exports, "isSnapRpcError", { enumerable: true, get: function () { return snapRpcError_1.isSnapRpcError; } });
|
|
12
18
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/utils/errors/index.ts"],"names":[],"mappings":";;;AAAA,+CAAyE;AAAhE,qHAAA,uBAAuB,OAAA;AAAE,8GAAA,gBAAgB,OAAA;AAClD,uCAA4E;AAAnE,0HAAA,gCAAgC,OAAA;AAAE,wGAAA,cAAc,OAAA;AACzD,mDAAgD;AAAvC,8GAAA,cAAc,OAAA","sourcesContent":["export { createSnapErrorHandling, createTrackError } from './trackError';\nexport { createWithCatchAndThrowSnapError, normalizeError } from './errors';\nexport { isSnapRpcError } from './snapRpcError';\nexport type {\n CreateSnapErrorHandlingOptions,\n CreateTrackErrorOptions,\n PrepareErrorForTrackingFn,\n ShouldTrackErrorFn,\n SnapTrackErrorRequest,\n TrackErrorCapableProvider,\n} from './trackError';\nexport type {\n CreateWithCatchAndThrowSnapErrorOptions,\n LogErrorFn,\n NormalizeErrorFn,\n TrackErrorFn,\n} from './errors';\nexport type { SnapRpcError } from './snapRpcError';\n"]}
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/utils/errors/index.ts"],"names":[],"mappings":";;;AAAA,+CAAyE;AAAhE,qHAAA,uBAAuB,OAAA;AAAE,8GAAA,gBAAgB,OAAA;AAClD,6CAIqB;AAHnB,iHAAA,oBAAoB,OAAA;AACpB,sHAAA,yBAAyB,OAAA;AACzB,6HAAA,gCAAgC,OAAA;AAGlC,uCAA4E;AAAnE,0HAAA,gCAAgC,OAAA;AAAE,wGAAA,cAAc,OAAA;AACzD,yDAAoD;AAA3C,kHAAA,eAAe,OAAA;AACxB,mDAAgD;AAAvC,8GAAA,cAAc,OAAA","sourcesContent":["export { createSnapErrorHandling, createTrackError } from './trackError';\nexport {\n SynchronizationError,\n formatAccountSyncFailures,\n getSyncFailuresFromSettledResult,\n} from './syncError';\nexport type { AccountSyncFailure } from './syncError';\nexport { createWithCatchAndThrowSnapError, normalizeError } from './errors';\nexport { stringifyReason } from './stringifyReason';\nexport { isSnapRpcError } from './snapRpcError';\nexport type {\n CreateSnapErrorHandlingOptions,\n CreateTrackErrorOptions,\n PrepareErrorForTrackingFn,\n ShouldTrackErrorFn,\n SnapTrackErrorRequest,\n TrackErrorCapableProvider,\n} from './trackError';\nexport type {\n CreateWithCatchAndThrowSnapErrorOptions,\n LogErrorFn,\n NormalizeErrorFn,\n TrackErrorFn,\n} from './errors';\nexport type { SnapRpcError } from './snapRpcError';\n"]}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export { createSnapErrorHandling, createTrackError } from "./trackError.cjs";
|
|
2
|
+
export { SynchronizationError, formatAccountSyncFailures, getSyncFailuresFromSettledResult, } from "./syncError.cjs";
|
|
3
|
+
export type { AccountSyncFailure } from "./syncError.cjs";
|
|
2
4
|
export { createWithCatchAndThrowSnapError, normalizeError } from "./errors.cjs";
|
|
5
|
+
export { stringifyReason } from "./stringifyReason.cjs";
|
|
3
6
|
export { isSnapRpcError } from "./snapRpcError.cjs";
|
|
4
7
|
export type { CreateSnapErrorHandlingOptions, CreateTrackErrorOptions, PrepareErrorForTrackingFn, ShouldTrackErrorFn, SnapTrackErrorRequest, TrackErrorCapableProvider, } from "./trackError.cjs";
|
|
5
8
|
export type { CreateWithCatchAndThrowSnapErrorOptions, LogErrorFn, NormalizeErrorFn, TrackErrorFn, } from "./errors.cjs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/utils/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,yBAAqB;AACzE,OAAO,EAAE,gCAAgC,EAAE,cAAc,EAAE,qBAAiB;AAC5E,OAAO,EAAE,cAAc,EAAE,2BAAuB;AAChD,YAAY,EACV,8BAA8B,EAC9B,uBAAuB,EACvB,yBAAyB,EACzB,kBAAkB,EAClB,qBAAqB,EACrB,yBAAyB,GAC1B,yBAAqB;AACtB,YAAY,EACV,uCAAuC,EACvC,UAAU,EACV,gBAAgB,EAChB,YAAY,GACb,qBAAiB;AAClB,YAAY,EAAE,YAAY,EAAE,2BAAuB"}
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/utils/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,yBAAqB;AACzE,OAAO,EACL,oBAAoB,EACpB,yBAAyB,EACzB,gCAAgC,GACjC,wBAAoB;AACrB,YAAY,EAAE,kBAAkB,EAAE,wBAAoB;AACtD,OAAO,EAAE,gCAAgC,EAAE,cAAc,EAAE,qBAAiB;AAC5E,OAAO,EAAE,eAAe,EAAE,8BAA0B;AACpD,OAAO,EAAE,cAAc,EAAE,2BAAuB;AAChD,YAAY,EACV,8BAA8B,EAC9B,uBAAuB,EACvB,yBAAyB,EACzB,kBAAkB,EAClB,qBAAqB,EACrB,yBAAyB,GAC1B,yBAAqB;AACtB,YAAY,EACV,uCAAuC,EACvC,UAAU,EACV,gBAAgB,EAChB,YAAY,GACb,qBAAiB;AAClB,YAAY,EAAE,YAAY,EAAE,2BAAuB"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export { createSnapErrorHandling, createTrackError } from "./trackError.mjs";
|
|
2
|
+
export { SynchronizationError, formatAccountSyncFailures, getSyncFailuresFromSettledResult, } from "./syncError.mjs";
|
|
3
|
+
export type { AccountSyncFailure } from "./syncError.mjs";
|
|
2
4
|
export { createWithCatchAndThrowSnapError, normalizeError } from "./errors.mjs";
|
|
5
|
+
export { stringifyReason } from "./stringifyReason.mjs";
|
|
3
6
|
export { isSnapRpcError } from "./snapRpcError.mjs";
|
|
4
7
|
export type { CreateSnapErrorHandlingOptions, CreateTrackErrorOptions, PrepareErrorForTrackingFn, ShouldTrackErrorFn, SnapTrackErrorRequest, TrackErrorCapableProvider, } from "./trackError.mjs";
|
|
5
8
|
export type { CreateWithCatchAndThrowSnapErrorOptions, LogErrorFn, NormalizeErrorFn, TrackErrorFn, } from "./errors.mjs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/utils/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,yBAAqB;AACzE,OAAO,EAAE,gCAAgC,EAAE,cAAc,EAAE,qBAAiB;AAC5E,OAAO,EAAE,cAAc,EAAE,2BAAuB;AAChD,YAAY,EACV,8BAA8B,EAC9B,uBAAuB,EACvB,yBAAyB,EACzB,kBAAkB,EAClB,qBAAqB,EACrB,yBAAyB,GAC1B,yBAAqB;AACtB,YAAY,EACV,uCAAuC,EACvC,UAAU,EACV,gBAAgB,EAChB,YAAY,GACb,qBAAiB;AAClB,YAAY,EAAE,YAAY,EAAE,2BAAuB"}
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/utils/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,yBAAqB;AACzE,OAAO,EACL,oBAAoB,EACpB,yBAAyB,EACzB,gCAAgC,GACjC,wBAAoB;AACrB,YAAY,EAAE,kBAAkB,EAAE,wBAAoB;AACtD,OAAO,EAAE,gCAAgC,EAAE,cAAc,EAAE,qBAAiB;AAC5E,OAAO,EAAE,eAAe,EAAE,8BAA0B;AACpD,OAAO,EAAE,cAAc,EAAE,2BAAuB;AAChD,YAAY,EACV,8BAA8B,EAC9B,uBAAuB,EACvB,yBAAyB,EACzB,kBAAkB,EAClB,qBAAqB,EACrB,yBAAyB,GAC1B,yBAAqB;AACtB,YAAY,EACV,uCAAuC,EACvC,UAAU,EACV,gBAAgB,EAChB,YAAY,GACb,qBAAiB;AAClB,YAAY,EAAE,YAAY,EAAE,2BAAuB"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { createSnapErrorHandling, createTrackError } from "./trackError.mjs";
|
|
2
|
+
export { SynchronizationError, formatAccountSyncFailures, getSyncFailuresFromSettledResult } from "./syncError.mjs";
|
|
2
3
|
export { createWithCatchAndThrowSnapError, normalizeError } from "./errors.mjs";
|
|
4
|
+
export { stringifyReason } from "./stringifyReason.mjs";
|
|
3
5
|
export { isSnapRpcError } from "./snapRpcError.mjs";
|
|
4
6
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/utils/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,yBAAqB;AACzE,OAAO,EAAE,gCAAgC,EAAE,cAAc,EAAE,qBAAiB;AAC5E,OAAO,EAAE,cAAc,EAAE,2BAAuB","sourcesContent":["export { createSnapErrorHandling, createTrackError } from './trackError';\nexport { createWithCatchAndThrowSnapError, normalizeError } from './errors';\nexport { isSnapRpcError } from './snapRpcError';\nexport type {\n CreateSnapErrorHandlingOptions,\n CreateTrackErrorOptions,\n PrepareErrorForTrackingFn,\n ShouldTrackErrorFn,\n SnapTrackErrorRequest,\n TrackErrorCapableProvider,\n} from './trackError';\nexport type {\n CreateWithCatchAndThrowSnapErrorOptions,\n LogErrorFn,\n NormalizeErrorFn,\n TrackErrorFn,\n} from './errors';\nexport type { SnapRpcError } from './snapRpcError';\n"]}
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/utils/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,yBAAqB;AACzE,OAAO,EACL,oBAAoB,EACpB,yBAAyB,EACzB,gCAAgC,EACjC,wBAAoB;AAErB,OAAO,EAAE,gCAAgC,EAAE,cAAc,EAAE,qBAAiB;AAC5E,OAAO,EAAE,eAAe,EAAE,8BAA0B;AACpD,OAAO,EAAE,cAAc,EAAE,2BAAuB","sourcesContent":["export { createSnapErrorHandling, createTrackError } from './trackError';\nexport {\n SynchronizationError,\n formatAccountSyncFailures,\n getSyncFailuresFromSettledResult,\n} from './syncError';\nexport type { AccountSyncFailure } from './syncError';\nexport { createWithCatchAndThrowSnapError, normalizeError } from './errors';\nexport { stringifyReason } from './stringifyReason';\nexport { isSnapRpcError } from './snapRpcError';\nexport type {\n CreateSnapErrorHandlingOptions,\n CreateTrackErrorOptions,\n PrepareErrorForTrackingFn,\n ShouldTrackErrorFn,\n SnapTrackErrorRequest,\n TrackErrorCapableProvider,\n} from './trackError';\nexport type {\n CreateWithCatchAndThrowSnapErrorOptions,\n LogErrorFn,\n NormalizeErrorFn,\n TrackErrorFn,\n} from './errors';\nexport type { SnapRpcError } from './snapRpcError';\n"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stringifyReason = stringifyReason;
|
|
4
|
+
/**
|
|
5
|
+
* Stringifies a rejection reason without ever throwing: `String(reason)`
|
|
6
|
+
* throws when the reason has a hostile `toString`/`Symbol.toPrimitive`. If the
|
|
7
|
+
* reason is an error with a `cause`, the cause is appended, so the wrapped
|
|
8
|
+
* failure (e.g. the underlying network error) is part of the reported reason.
|
|
9
|
+
*
|
|
10
|
+
* Intended for building human-readable failure reasons (e.g. for
|
|
11
|
+
* `AccountSyncFailure.reason`), where wrapper errors would otherwise hide the
|
|
12
|
+
* original failure behind a generic message.
|
|
13
|
+
*
|
|
14
|
+
* @param reason - The rejection reason to stringify.
|
|
15
|
+
* @returns The reason as a string, or a placeholder when stringification fails.
|
|
16
|
+
*/
|
|
17
|
+
function stringifyReason(reason) {
|
|
18
|
+
try {
|
|
19
|
+
if (!(reason instanceof Error)) {
|
|
20
|
+
return String(reason);
|
|
21
|
+
}
|
|
22
|
+
const message = String(reason);
|
|
23
|
+
const { cause } = reason;
|
|
24
|
+
if (cause === null || cause === undefined) {
|
|
25
|
+
return message;
|
|
26
|
+
}
|
|
27
|
+
// Deliberately permissive: any cause detail is worth reporting, and a
|
|
28
|
+
// pathological value still ends up as the placeholder via the outer catch.
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
30
|
+
return `${message} (${String(cause)})`;
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return 'Unknown error';
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=stringifyReason.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stringifyReason.cjs","sourceRoot":"","sources":["../../../src/utils/errors/stringifyReason.ts"],"names":[],"mappings":";;AAaA,0CAoBC;AAjCD;;;;;;;;;;;;GAYG;AACH,SAAgB,eAAe,CAAC,MAAe;IAC7C,IAAI,CAAC;QACH,IAAI,CAAC,CAAC,MAAM,YAAY,KAAK,CAAC,EAAE,CAAC;YAC/B,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC;QACxB,CAAC;QAED,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;QAC/B,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;QAEzB,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YAC1C,OAAO,OAAO,CAAC;QACjB,CAAC;QAED,sEAAsE;QACtE,2EAA2E;QAC3E,gEAAgE;QAChE,OAAO,GAAG,OAAO,KAAK,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC;IACzC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,eAAe,CAAC;IACzB,CAAC;AACH,CAAC","sourcesContent":["/**\n * Stringifies a rejection reason without ever throwing: `String(reason)`\n * throws when the reason has a hostile `toString`/`Symbol.toPrimitive`. If the\n * reason is an error with a `cause`, the cause is appended, so the wrapped\n * failure (e.g. the underlying network error) is part of the reported reason.\n *\n * Intended for building human-readable failure reasons (e.g. for\n * `AccountSyncFailure.reason`), where wrapper errors would otherwise hide the\n * original failure behind a generic message.\n *\n * @param reason - The rejection reason to stringify.\n * @returns The reason as a string, or a placeholder when stringification fails.\n */\nexport function stringifyReason(reason: unknown): string {\n try {\n if (!(reason instanceof Error)) {\n return String(reason);\n }\n\n const message = String(reason);\n const { cause } = reason;\n\n if (cause === null || cause === undefined) {\n return message;\n }\n\n // Deliberately permissive: any cause detail is worth reporting, and a\n // pathological value still ends up as the placeholder via the outer catch.\n // eslint-disable-next-line @typescript-eslint/no-base-to-string\n return `${message} (${String(cause)})`;\n } catch {\n return 'Unknown error';\n }\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stringifies a rejection reason without ever throwing: `String(reason)`
|
|
3
|
+
* throws when the reason has a hostile `toString`/`Symbol.toPrimitive`. If the
|
|
4
|
+
* reason is an error with a `cause`, the cause is appended, so the wrapped
|
|
5
|
+
* failure (e.g. the underlying network error) is part of the reported reason.
|
|
6
|
+
*
|
|
7
|
+
* Intended for building human-readable failure reasons (e.g. for
|
|
8
|
+
* `AccountSyncFailure.reason`), where wrapper errors would otherwise hide the
|
|
9
|
+
* original failure behind a generic message.
|
|
10
|
+
*
|
|
11
|
+
* @param reason - The rejection reason to stringify.
|
|
12
|
+
* @returns The reason as a string, or a placeholder when stringification fails.
|
|
13
|
+
*/
|
|
14
|
+
export declare function stringifyReason(reason: unknown): string;
|
|
15
|
+
//# sourceMappingURL=stringifyReason.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stringifyReason.d.cts","sourceRoot":"","sources":["../../../src/utils/errors/stringifyReason.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAoBvD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stringifies a rejection reason without ever throwing: `String(reason)`
|
|
3
|
+
* throws when the reason has a hostile `toString`/`Symbol.toPrimitive`. If the
|
|
4
|
+
* reason is an error with a `cause`, the cause is appended, so the wrapped
|
|
5
|
+
* failure (e.g. the underlying network error) is part of the reported reason.
|
|
6
|
+
*
|
|
7
|
+
* Intended for building human-readable failure reasons (e.g. for
|
|
8
|
+
* `AccountSyncFailure.reason`), where wrapper errors would otherwise hide the
|
|
9
|
+
* original failure behind a generic message.
|
|
10
|
+
*
|
|
11
|
+
* @param reason - The rejection reason to stringify.
|
|
12
|
+
* @returns The reason as a string, or a placeholder when stringification fails.
|
|
13
|
+
*/
|
|
14
|
+
export declare function stringifyReason(reason: unknown): string;
|
|
15
|
+
//# sourceMappingURL=stringifyReason.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stringifyReason.d.mts","sourceRoot":"","sources":["../../../src/utils/errors/stringifyReason.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAoBvD"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stringifies a rejection reason without ever throwing: `String(reason)`
|
|
3
|
+
* throws when the reason has a hostile `toString`/`Symbol.toPrimitive`. If the
|
|
4
|
+
* reason is an error with a `cause`, the cause is appended, so the wrapped
|
|
5
|
+
* failure (e.g. the underlying network error) is part of the reported reason.
|
|
6
|
+
*
|
|
7
|
+
* Intended for building human-readable failure reasons (e.g. for
|
|
8
|
+
* `AccountSyncFailure.reason`), where wrapper errors would otherwise hide the
|
|
9
|
+
* original failure behind a generic message.
|
|
10
|
+
*
|
|
11
|
+
* @param reason - The rejection reason to stringify.
|
|
12
|
+
* @returns The reason as a string, or a placeholder when stringification fails.
|
|
13
|
+
*/
|
|
14
|
+
export function stringifyReason(reason) {
|
|
15
|
+
try {
|
|
16
|
+
if (!(reason instanceof Error)) {
|
|
17
|
+
return String(reason);
|
|
18
|
+
}
|
|
19
|
+
const message = String(reason);
|
|
20
|
+
const { cause } = reason;
|
|
21
|
+
if (cause === null || cause === undefined) {
|
|
22
|
+
return message;
|
|
23
|
+
}
|
|
24
|
+
// Deliberately permissive: any cause detail is worth reporting, and a
|
|
25
|
+
// pathological value still ends up as the placeholder via the outer catch.
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
27
|
+
return `${message} (${String(cause)})`;
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return 'Unknown error';
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=stringifyReason.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stringifyReason.mjs","sourceRoot":"","sources":["../../../src/utils/errors/stringifyReason.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,eAAe,CAAC,MAAe;IAC7C,IAAI,CAAC;QACH,IAAI,CAAC,CAAC,MAAM,YAAY,KAAK,CAAC,EAAE,CAAC;YAC/B,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC;QACxB,CAAC;QAED,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;QAC/B,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;QAEzB,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YAC1C,OAAO,OAAO,CAAC;QACjB,CAAC;QAED,sEAAsE;QACtE,2EAA2E;QAC3E,gEAAgE;QAChE,OAAO,GAAG,OAAO,KAAK,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC;IACzC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,eAAe,CAAC;IACzB,CAAC;AACH,CAAC","sourcesContent":["/**\n * Stringifies a rejection reason without ever throwing: `String(reason)`\n * throws when the reason has a hostile `toString`/`Symbol.toPrimitive`. If the\n * reason is an error with a `cause`, the cause is appended, so the wrapped\n * failure (e.g. the underlying network error) is part of the reported reason.\n *\n * Intended for building human-readable failure reasons (e.g. for\n * `AccountSyncFailure.reason`), where wrapper errors would otherwise hide the\n * original failure behind a generic message.\n *\n * @param reason - The rejection reason to stringify.\n * @returns The reason as a string, or a placeholder when stringification fails.\n */\nexport function stringifyReason(reason: unknown): string {\n try {\n if (!(reason instanceof Error)) {\n return String(reason);\n }\n\n const message = String(reason);\n const { cause } = reason;\n\n if (cause === null || cause === undefined) {\n return message;\n }\n\n // Deliberately permissive: any cause detail is worth reporting, and a\n // pathological value still ends up as the placeholder via the outer catch.\n // eslint-disable-next-line @typescript-eslint/no-base-to-string\n return `${message} (${String(cause)})`;\n } catch {\n return 'Unknown error';\n }\n}\n"]}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SynchronizationError = void 0;
|
|
4
|
+
exports.getSyncFailuresFromSettledResult = getSyncFailuresFromSettledResult;
|
|
5
|
+
exports.formatAccountSyncFailures = formatAccountSyncFailures;
|
|
6
|
+
const stringifyReason_1 = require("./stringifyReason.cjs");
|
|
7
|
+
/**
|
|
8
|
+
* Maps settled synchronization results to account synchronization failures:
|
|
9
|
+
* each rejection is attributed to the account ID at the same index
|
|
10
|
+
* (`Promise.allSettled` preserves order).
|
|
11
|
+
*
|
|
12
|
+
* Rejection reasons are stringified with {@link stringifyReason}, so wrapped
|
|
13
|
+
* errors report their cause as well.
|
|
14
|
+
*
|
|
15
|
+
* @param results - The settled synchronization results.
|
|
16
|
+
* @param accountIds - The account IDs, in the same order as `results`.
|
|
17
|
+
* @returns The collected failures, in results order.
|
|
18
|
+
*/
|
|
19
|
+
function getSyncFailuresFromSettledResult(results, accountIds) {
|
|
20
|
+
const failures = [];
|
|
21
|
+
results.forEach((result, index) => {
|
|
22
|
+
const accountId = accountIds[index];
|
|
23
|
+
if (accountId && result.status === 'rejected') {
|
|
24
|
+
failures.push({
|
|
25
|
+
accountId,
|
|
26
|
+
reason: (0, stringifyReason_1.stringifyReason)(result.reason),
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
return failures;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Maximum number of characters kept from each failure reason. Reasons can be
|
|
34
|
+
* arbitrarily long (e.g. full network error messages), so they are truncated
|
|
35
|
+
* to keep the error message readable in Sentry.
|
|
36
|
+
*/
|
|
37
|
+
const MAX_REASON_LENGTH = 300;
|
|
38
|
+
/**
|
|
39
|
+
* Maximum number of failures listed in the error message. When more accounts
|
|
40
|
+
* fail, the remaining ones are summarized with a `+N more` suffix.
|
|
41
|
+
*/
|
|
42
|
+
const MAX_LISTED_FAILURES = 10;
|
|
43
|
+
/**
|
|
44
|
+
* Formats account synchronization failures as a compact, single-line summary.
|
|
45
|
+
*
|
|
46
|
+
* The summary is intended to be embedded in the error message of a
|
|
47
|
+
* `SynchronizationError`: error tracking via `snap_trackError` serializes only
|
|
48
|
+
* the error's `name`, `message`, `stack`, and `cause`, so any details stored in
|
|
49
|
+
* other properties (e.g. a `data` field) are lost before reaching Sentry.
|
|
50
|
+
*
|
|
51
|
+
* @param failures - The account synchronization failures to format.
|
|
52
|
+
* @returns A single-line summary of the failures, truncated to keep the
|
|
53
|
+
* message readable.
|
|
54
|
+
*/
|
|
55
|
+
function formatAccountSyncFailures(failures) {
|
|
56
|
+
const listed = failures.slice(0, MAX_LISTED_FAILURES);
|
|
57
|
+
const details = listed.map((failure) => {
|
|
58
|
+
const reason = failure.reason.length > MAX_REASON_LENGTH
|
|
59
|
+
? `${failure.reason.slice(0, MAX_REASON_LENGTH)}…`
|
|
60
|
+
: failure.reason;
|
|
61
|
+
return `${failure.accountId}: ${reason}`;
|
|
62
|
+
});
|
|
63
|
+
const remaining = failures.length - listed.length;
|
|
64
|
+
const suffix = remaining > 0 ? `; +${remaining} more` : '';
|
|
65
|
+
return `${details.join('; ')}${suffix}`;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Error thrown when one or more accounts fail to synchronize.
|
|
69
|
+
*
|
|
70
|
+
* The failure details are embedded in the message (not only in a property) so
|
|
71
|
+
* that they survive error tracking: `snap_trackError` serializes only the
|
|
72
|
+
* error's `name`, `message`, `stack`, and `cause`.
|
|
73
|
+
*/
|
|
74
|
+
class SynchronizationError extends Error {
|
|
75
|
+
/**
|
|
76
|
+
* The structured list of account synchronization failures. Useful for logs;
|
|
77
|
+
* note that it is not preserved by error tracking.
|
|
78
|
+
*/
|
|
79
|
+
failures;
|
|
80
|
+
/**
|
|
81
|
+
* Construct a new synchronization error.
|
|
82
|
+
*
|
|
83
|
+
* @param message - The error message, e.g. `'Account synchronization failures'`.
|
|
84
|
+
* @param failures - The per-account failures to append to the message.
|
|
85
|
+
* @param options - Additional error options.
|
|
86
|
+
* @param options.cause - The underlying error that caused the synchronization failure, if any.
|
|
87
|
+
*/
|
|
88
|
+
constructor(message, failures = [], options) {
|
|
89
|
+
const details = failures.length > 0
|
|
90
|
+
? ` (${failures.length} failed): ${formatAccountSyncFailures(failures)}`
|
|
91
|
+
: '';
|
|
92
|
+
super(`${message}${details}`, options);
|
|
93
|
+
this.name = 'SynchronizationError';
|
|
94
|
+
this.failures = failures;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
exports.SynchronizationError = SynchronizationError;
|
|
98
|
+
//# sourceMappingURL=syncError.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"syncError.cjs","sourceRoot":"","sources":["../../../src/utils/errors/syncError.ts"],"names":[],"mappings":";;;AAyBA,4EAiBC;AA2BD,8DAiBC;AAtFD,2DAAoD;AAapD;;;;;;;;;;;GAWG;AACH,SAAgB,gCAAgC,CAC9C,OAAwC,EACxC,UAAoB;IAEpB,MAAM,QAAQ,GAAyB,EAAE,CAAC;IAE1C,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;QAChC,MAAM,SAAS,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;QACpC,IAAI,SAAS,IAAI,MAAM,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;YAC9C,QAAQ,CAAC,IAAI,CAAC;gBACZ,SAAS;gBACT,MAAM,EAAE,IAAA,iCAAe,EAAC,MAAM,CAAC,MAAM,CAAC;aACvC,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;GAIG;AACH,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAE9B;;;GAGG;AACH,MAAM,mBAAmB,GAAG,EAAE,CAAC;AA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,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF;AA7BD,oDA6BC","sourcesContent":["import { stringifyReason } from './stringifyReason';\n\n/**\n * A single account synchronization failure, with enough context to understand\n * which account failed and why.\n */\nexport type AccountSyncFailure = {\n /** The ID of the account that failed to synchronize. */\n accountId: string;\n /** The failure reason, as a human-readable string. */\n reason: string;\n};\n\n/**\n * Maps settled synchronization results to account synchronization failures:\n * each rejection is attributed to the account ID at the same index\n * (`Promise.allSettled` preserves order).\n *\n * Rejection reasons are stringified with {@link stringifyReason}, so wrapped\n * errors report their cause as well.\n *\n * @param results - The settled synchronization results.\n * @param accountIds - The account IDs, in the same order as `results`.\n * @returns The collected failures, in results order.\n */\nexport function getSyncFailuresFromSettledResult(\n results: PromiseSettledResult<unknown>[],\n accountIds: string[],\n): AccountSyncFailure[] {\n const failures: AccountSyncFailure[] = [];\n\n results.forEach((result, index) => {\n const accountId = accountIds[index];\n if (accountId && result.status === 'rejected') {\n failures.push({\n accountId,\n reason: stringifyReason(result.reason),\n });\n }\n });\n\n return failures;\n}\n\n/**\n * Maximum number of characters kept from each failure reason. Reasons can be\n * arbitrarily long (e.g. full network error messages), so they are truncated\n * to keep the error message readable in Sentry.\n */\nconst MAX_REASON_LENGTH = 300;\n\n/**\n * Maximum number of failures listed in the error message. When more accounts\n * fail, the remaining ones are summarized with a `+N more` suffix.\n */\nconst MAX_LISTED_FAILURES = 10;\n\n/**\n * Formats account synchronization failures as a compact, single-line summary.\n *\n * The summary is intended to be embedded in the error message of a\n * `SynchronizationError`: error tracking via `snap_trackError` serializes only\n * the error's `name`, `message`, `stack`, and `cause`, so any details stored in\n * other properties (e.g. a `data` field) are lost before reaching Sentry.\n *\n * @param failures - The account synchronization failures to format.\n * @returns A single-line summary of the failures, truncated to keep the\n * message readable.\n */\nexport function formatAccountSyncFailures(\n failures: AccountSyncFailure[],\n): string {\n const listed = failures.slice(0, MAX_LISTED_FAILURES);\n const details = listed.map((failure) => {\n const reason =\n failure.reason.length > MAX_REASON_LENGTH\n ? `${failure.reason.slice(0, MAX_REASON_LENGTH)}…`\n : failure.reason;\n\n return `${failure.accountId}: ${reason}`;\n });\n\n const remaining = failures.length - listed.length;\n const suffix = remaining > 0 ? `; +${remaining} more` : '';\n\n return `${details.join('; ')}${suffix}`;\n}\n\n/**\n * Error thrown when one or more accounts fail to synchronize.\n *\n * The failure details are embedded in the message (not only in a property) so\n * that they survive error tracking: `snap_trackError` serializes only the\n * error's `name`, `message`, `stack`, and `cause`.\n */\nexport class SynchronizationError extends Error {\n /**\n * The structured list of account synchronization failures. Useful for logs;\n * note that it is not preserved by error tracking.\n */\n readonly failures: AccountSyncFailure[];\n\n /**\n * Construct a new synchronization error.\n *\n * @param message - The error message, e.g. `'Account synchronization failures'`.\n * @param failures - The per-account failures to append to the message.\n * @param options - Additional error options.\n * @param options.cause - The underlying error that caused the synchronization failure, if any.\n */\n constructor(\n message: string,\n failures: AccountSyncFailure[] = [],\n options?: ErrorOptions,\n ) {\n const details =\n failures.length > 0\n ? ` (${failures.length} failed): ${formatAccountSyncFailures(failures)}`\n : '';\n\n super(`${message}${details}`, options);\n this.name = 'SynchronizationError';\n this.failures = failures;\n }\n}\n"]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A single account synchronization failure, with enough context to understand
|
|
3
|
+
* which account failed and why.
|
|
4
|
+
*/
|
|
5
|
+
export type AccountSyncFailure = {
|
|
6
|
+
/** The ID of the account that failed to synchronize. */
|
|
7
|
+
accountId: string;
|
|
8
|
+
/** The failure reason, as a human-readable string. */
|
|
9
|
+
reason: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Maps settled synchronization results to account synchronization failures:
|
|
13
|
+
* each rejection is attributed to the account ID at the same index
|
|
14
|
+
* (`Promise.allSettled` preserves order).
|
|
15
|
+
*
|
|
16
|
+
* Rejection reasons are stringified with {@link stringifyReason}, so wrapped
|
|
17
|
+
* errors report their cause as well.
|
|
18
|
+
*
|
|
19
|
+
* @param results - The settled synchronization results.
|
|
20
|
+
* @param accountIds - The account IDs, in the same order as `results`.
|
|
21
|
+
* @returns The collected failures, in results order.
|
|
22
|
+
*/
|
|
23
|
+
export declare function getSyncFailuresFromSettledResult(results: PromiseSettledResult<unknown>[], accountIds: string[]): AccountSyncFailure[];
|
|
24
|
+
/**
|
|
25
|
+
* Formats account synchronization failures as a compact, single-line summary.
|
|
26
|
+
*
|
|
27
|
+
* The summary is intended to be embedded in the error message of a
|
|
28
|
+
* `SynchronizationError`: error tracking via `snap_trackError` serializes only
|
|
29
|
+
* the error's `name`, `message`, `stack`, and `cause`, so any details stored in
|
|
30
|
+
* other properties (e.g. a `data` field) are lost before reaching Sentry.
|
|
31
|
+
*
|
|
32
|
+
* @param failures - The account synchronization failures to format.
|
|
33
|
+
* @returns A single-line summary of the failures, truncated to keep the
|
|
34
|
+
* message readable.
|
|
35
|
+
*/
|
|
36
|
+
export declare function formatAccountSyncFailures(failures: AccountSyncFailure[]): string;
|
|
37
|
+
/**
|
|
38
|
+
* Error thrown when one or more accounts fail to synchronize.
|
|
39
|
+
*
|
|
40
|
+
* The failure details are embedded in the message (not only in a property) so
|
|
41
|
+
* that they survive error tracking: `snap_trackError` serializes only the
|
|
42
|
+
* error's `name`, `message`, `stack`, and `cause`.
|
|
43
|
+
*/
|
|
44
|
+
export declare class SynchronizationError extends Error {
|
|
45
|
+
/**
|
|
46
|
+
* The structured list of account synchronization failures. Useful for logs;
|
|
47
|
+
* note that it is not preserved by error tracking.
|
|
48
|
+
*/
|
|
49
|
+
readonly failures: AccountSyncFailure[];
|
|
50
|
+
/**
|
|
51
|
+
* Construct a new synchronization error.
|
|
52
|
+
*
|
|
53
|
+
* @param message - The error message, e.g. `'Account synchronization failures'`.
|
|
54
|
+
* @param failures - The per-account failures to append to the message.
|
|
55
|
+
* @param options - Additional error options.
|
|
56
|
+
* @param options.cause - The underlying error that caused the synchronization failure, if any.
|
|
57
|
+
*/
|
|
58
|
+
constructor(message: string, failures?: AccountSyncFailure[], options?: ErrorOptions);
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=syncError.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"syncError.d.cts","sourceRoot":"","sources":["../../../src/utils/errors/syncError.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,wDAAwD;IACxD,SAAS,EAAE,MAAM,CAAC;IAClB,sDAAsD;IACtD,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,gCAAgC,CAC9C,OAAO,EAAE,oBAAoB,CAAC,OAAO,CAAC,EAAE,EACxC,UAAU,EAAE,MAAM,EAAE,GACnB,kBAAkB,EAAE,CActB;AAeD;;;;;;;;;;;GAWG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,kBAAkB,EAAE,GAC7B,MAAM,CAeR;AAED;;;;;;GAMG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,EAAE,CAAC;IAExC;;;;;;;OAOG;gBAED,OAAO,EAAE,MAAM,EACf,QAAQ,GAAE,kBAAkB,EAAO,EACnC,OAAO,CAAC,EAAE,YAAY;CAWzB"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A single account synchronization failure, with enough context to understand
|
|
3
|
+
* which account failed and why.
|
|
4
|
+
*/
|
|
5
|
+
export type AccountSyncFailure = {
|
|
6
|
+
/** The ID of the account that failed to synchronize. */
|
|
7
|
+
accountId: string;
|
|
8
|
+
/** The failure reason, as a human-readable string. */
|
|
9
|
+
reason: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Maps settled synchronization results to account synchronization failures:
|
|
13
|
+
* each rejection is attributed to the account ID at the same index
|
|
14
|
+
* (`Promise.allSettled` preserves order).
|
|
15
|
+
*
|
|
16
|
+
* Rejection reasons are stringified with {@link stringifyReason}, so wrapped
|
|
17
|
+
* errors report their cause as well.
|
|
18
|
+
*
|
|
19
|
+
* @param results - The settled synchronization results.
|
|
20
|
+
* @param accountIds - The account IDs, in the same order as `results`.
|
|
21
|
+
* @returns The collected failures, in results order.
|
|
22
|
+
*/
|
|
23
|
+
export declare function getSyncFailuresFromSettledResult(results: PromiseSettledResult<unknown>[], accountIds: string[]): AccountSyncFailure[];
|
|
24
|
+
/**
|
|
25
|
+
* Formats account synchronization failures as a compact, single-line summary.
|
|
26
|
+
*
|
|
27
|
+
* The summary is intended to be embedded in the error message of a
|
|
28
|
+
* `SynchronizationError`: error tracking via `snap_trackError` serializes only
|
|
29
|
+
* the error's `name`, `message`, `stack`, and `cause`, so any details stored in
|
|
30
|
+
* other properties (e.g. a `data` field) are lost before reaching Sentry.
|
|
31
|
+
*
|
|
32
|
+
* @param failures - The account synchronization failures to format.
|
|
33
|
+
* @returns A single-line summary of the failures, truncated to keep the
|
|
34
|
+
* message readable.
|
|
35
|
+
*/
|
|
36
|
+
export declare function formatAccountSyncFailures(failures: AccountSyncFailure[]): string;
|
|
37
|
+
/**
|
|
38
|
+
* Error thrown when one or more accounts fail to synchronize.
|
|
39
|
+
*
|
|
40
|
+
* The failure details are embedded in the message (not only in a property) so
|
|
41
|
+
* that they survive error tracking: `snap_trackError` serializes only the
|
|
42
|
+
* error's `name`, `message`, `stack`, and `cause`.
|
|
43
|
+
*/
|
|
44
|
+
export declare class SynchronizationError extends Error {
|
|
45
|
+
/**
|
|
46
|
+
* The structured list of account synchronization failures. Useful for logs;
|
|
47
|
+
* note that it is not preserved by error tracking.
|
|
48
|
+
*/
|
|
49
|
+
readonly failures: AccountSyncFailure[];
|
|
50
|
+
/**
|
|
51
|
+
* Construct a new synchronization error.
|
|
52
|
+
*
|
|
53
|
+
* @param message - The error message, e.g. `'Account synchronization failures'`.
|
|
54
|
+
* @param failures - The per-account failures to append to the message.
|
|
55
|
+
* @param options - Additional error options.
|
|
56
|
+
* @param options.cause - The underlying error that caused the synchronization failure, if any.
|
|
57
|
+
*/
|
|
58
|
+
constructor(message: string, failures?: AccountSyncFailure[], options?: ErrorOptions);
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=syncError.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"syncError.d.mts","sourceRoot":"","sources":["../../../src/utils/errors/syncError.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,wDAAwD;IACxD,SAAS,EAAE,MAAM,CAAC;IAClB,sDAAsD;IACtD,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,gCAAgC,CAC9C,OAAO,EAAE,oBAAoB,CAAC,OAAO,CAAC,EAAE,EACxC,UAAU,EAAE,MAAM,EAAE,GACnB,kBAAkB,EAAE,CActB;AAeD;;;;;;;;;;;GAWG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,kBAAkB,EAAE,GAC7B,MAAM,CAeR;AAED;;;;;;GAMG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,EAAE,CAAC;IAExC;;;;;;;OAOG;gBAED,OAAO,EAAE,MAAM,EACf,QAAQ,GAAE,kBAAkB,EAAO,EACnC,OAAO,CAAC,EAAE,YAAY;CAWzB"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { stringifyReason } from "./stringifyReason.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* Maps settled synchronization results to account synchronization failures:
|
|
4
|
+
* each rejection is attributed to the account ID at the same index
|
|
5
|
+
* (`Promise.allSettled` preserves order).
|
|
6
|
+
*
|
|
7
|
+
* Rejection reasons are stringified with {@link stringifyReason}, so wrapped
|
|
8
|
+
* errors report their cause as well.
|
|
9
|
+
*
|
|
10
|
+
* @param results - The settled synchronization results.
|
|
11
|
+
* @param accountIds - The account IDs, in the same order as `results`.
|
|
12
|
+
* @returns The collected failures, in results order.
|
|
13
|
+
*/
|
|
14
|
+
export function getSyncFailuresFromSettledResult(results, accountIds) {
|
|
15
|
+
const failures = [];
|
|
16
|
+
results.forEach((result, index) => {
|
|
17
|
+
const accountId = accountIds[index];
|
|
18
|
+
if (accountId && result.status === 'rejected') {
|
|
19
|
+
failures.push({
|
|
20
|
+
accountId,
|
|
21
|
+
reason: stringifyReason(result.reason),
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
return failures;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Maximum number of characters kept from each failure reason. Reasons can be
|
|
29
|
+
* arbitrarily long (e.g. full network error messages), so they are truncated
|
|
30
|
+
* to keep the error message readable in Sentry.
|
|
31
|
+
*/
|
|
32
|
+
const MAX_REASON_LENGTH = 300;
|
|
33
|
+
/**
|
|
34
|
+
* Maximum number of failures listed in the error message. When more accounts
|
|
35
|
+
* fail, the remaining ones are summarized with a `+N more` suffix.
|
|
36
|
+
*/
|
|
37
|
+
const MAX_LISTED_FAILURES = 10;
|
|
38
|
+
/**
|
|
39
|
+
* Formats account synchronization failures as a compact, single-line summary.
|
|
40
|
+
*
|
|
41
|
+
* The summary is intended to be embedded in the error message of a
|
|
42
|
+
* `SynchronizationError`: error tracking via `snap_trackError` serializes only
|
|
43
|
+
* the error's `name`, `message`, `stack`, and `cause`, so any details stored in
|
|
44
|
+
* other properties (e.g. a `data` field) are lost before reaching Sentry.
|
|
45
|
+
*
|
|
46
|
+
* @param failures - The account synchronization failures to format.
|
|
47
|
+
* @returns A single-line summary of the failures, truncated to keep the
|
|
48
|
+
* message readable.
|
|
49
|
+
*/
|
|
50
|
+
export function formatAccountSyncFailures(failures) {
|
|
51
|
+
const listed = failures.slice(0, MAX_LISTED_FAILURES);
|
|
52
|
+
const details = listed.map((failure) => {
|
|
53
|
+
const reason = failure.reason.length > MAX_REASON_LENGTH
|
|
54
|
+
? `${failure.reason.slice(0, MAX_REASON_LENGTH)}…`
|
|
55
|
+
: failure.reason;
|
|
56
|
+
return `${failure.accountId}: ${reason}`;
|
|
57
|
+
});
|
|
58
|
+
const remaining = failures.length - listed.length;
|
|
59
|
+
const suffix = remaining > 0 ? `; +${remaining} more` : '';
|
|
60
|
+
return `${details.join('; ')}${suffix}`;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Error thrown when one or more accounts fail to synchronize.
|
|
64
|
+
*
|
|
65
|
+
* The failure details are embedded in the message (not only in a property) so
|
|
66
|
+
* that they survive error tracking: `snap_trackError` serializes only the
|
|
67
|
+
* error's `name`, `message`, `stack`, and `cause`.
|
|
68
|
+
*/
|
|
69
|
+
export class SynchronizationError extends Error {
|
|
70
|
+
/**
|
|
71
|
+
* The structured list of account synchronization failures. Useful for logs;
|
|
72
|
+
* note that it is not preserved by error tracking.
|
|
73
|
+
*/
|
|
74
|
+
failures;
|
|
75
|
+
/**
|
|
76
|
+
* Construct a new synchronization error.
|
|
77
|
+
*
|
|
78
|
+
* @param message - The error message, e.g. `'Account synchronization failures'`.
|
|
79
|
+
* @param failures - The per-account failures to append to the message.
|
|
80
|
+
* @param options - Additional error options.
|
|
81
|
+
* @param options.cause - The underlying error that caused the synchronization failure, if any.
|
|
82
|
+
*/
|
|
83
|
+
constructor(message, failures = [], options) {
|
|
84
|
+
const details = failures.length > 0
|
|
85
|
+
? ` (${failures.length} failed): ${formatAccountSyncFailures(failures)}`
|
|
86
|
+
: '';
|
|
87
|
+
super(`${message}${details}`, options);
|
|
88
|
+
this.name = 'SynchronizationError';
|
|
89
|
+
this.failures = failures;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=syncError.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"syncError.mjs","sourceRoot":"","sources":["../../../src/utils/errors/syncError.ts"],"names":[],"mappings":"AAAA,O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,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,SAAS,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;IAE3D,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,MAAM,EAAE,CAAC;AAC1C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAC7C;;;OAGG;IACM,QAAQ,CAAuB;IAExC;;;;;;;OAOG;IACH,YACE,OAAe,EACf,WAAiC,EAAE,EACnC,OAAsB;QAEtB,MAAM,OAAO,GACX,QAAQ,CAAC,MAAM,GAAG,CAAC;YACjB,CAAC,CAAC,KAAK,QAAQ,CAAC,MAAM,aAAa,yBAAyB,CAAC,QAAQ,CAAC,EAAE;YACxE,CAAC,CAAC,EAAE,CAAC;QAET,KAAK,CAAC,GAAG,OAAO,GAAG,OAAO,EAAE,EAAE,OAAO,CAAC,CAAC;QACvC,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;QACnC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF","sourcesContent":["import { stringifyReason } from './stringifyReason';\n\n/**\n * A single account synchronization failure, with enough context to understand\n * which account failed and why.\n */\nexport type AccountSyncFailure = {\n /** The ID of the account that failed to synchronize. */\n accountId: string;\n /** The failure reason, as a human-readable string. */\n reason: string;\n};\n\n/**\n * Maps settled synchronization results to account synchronization failures:\n * each rejection is attributed to the account ID at the same index\n * (`Promise.allSettled` preserves order).\n *\n * Rejection reasons are stringified with {@link stringifyReason}, so wrapped\n * errors report their cause as well.\n *\n * @param results - The settled synchronization results.\n * @param accountIds - The account IDs, in the same order as `results`.\n * @returns The collected failures, in results order.\n */\nexport function getSyncFailuresFromSettledResult(\n results: PromiseSettledResult<unknown>[],\n accountIds: string[],\n): AccountSyncFailure[] {\n const failures: AccountSyncFailure[] = [];\n\n results.forEach((result, index) => {\n const accountId = accountIds[index];\n if (accountId && result.status === 'rejected') {\n failures.push({\n accountId,\n reason: stringifyReason(result.reason),\n });\n }\n });\n\n return failures;\n}\n\n/**\n * Maximum number of characters kept from each failure reason. Reasons can be\n * arbitrarily long (e.g. full network error messages), so they are truncated\n * to keep the error message readable in Sentry.\n */\nconst MAX_REASON_LENGTH = 300;\n\n/**\n * Maximum number of failures listed in the error message. When more accounts\n * fail, the remaining ones are summarized with a `+N more` suffix.\n */\nconst MAX_LISTED_FAILURES = 10;\n\n/**\n * Formats account synchronization failures as a compact, single-line summary.\n *\n * The summary is intended to be embedded in the error message of a\n * `SynchronizationError`: error tracking via `snap_trackError` serializes only\n * the error's `name`, `message`, `stack`, and `cause`, so any details stored in\n * other properties (e.g. a `data` field) are lost before reaching Sentry.\n *\n * @param failures - The account synchronization failures to format.\n * @returns A single-line summary of the failures, truncated to keep the\n * message readable.\n */\nexport function formatAccountSyncFailures(\n failures: AccountSyncFailure[],\n): string {\n const listed = failures.slice(0, MAX_LISTED_FAILURES);\n const details = listed.map((failure) => {\n const reason =\n failure.reason.length > MAX_REASON_LENGTH\n ? `${failure.reason.slice(0, MAX_REASON_LENGTH)}…`\n : failure.reason;\n\n return `${failure.accountId}: ${reason}`;\n });\n\n const remaining = failures.length - listed.length;\n const suffix = remaining > 0 ? `; +${remaining} more` : '';\n\n return `${details.join('; ')}${suffix}`;\n}\n\n/**\n * Error thrown when one or more accounts fail to synchronize.\n *\n * The failure details are embedded in the message (not only in a property) so\n * that they survive error tracking: `snap_trackError` serializes only the\n * error's `name`, `message`, `stack`, and `cause`.\n */\nexport class SynchronizationError extends Error {\n /**\n * The structured list of account synchronization failures. Useful for logs;\n * note that it is not preserved by error tracking.\n */\n readonly failures: AccountSyncFailure[];\n\n /**\n * Construct a new synchronization error.\n *\n * @param message - The error message, e.g. `'Account synchronization failures'`.\n * @param failures - The per-account failures to append to the message.\n * @param options - Additional error options.\n * @param options.cause - The underlying error that caused the synchronization failure, if any.\n */\n constructor(\n message: string,\n failures: AccountSyncFailure[] = [],\n options?: ErrorOptions,\n ) {\n const details =\n failures.length > 0\n ? ` (${failures.length} failed): ${formatAccountSyncFailures(failures)}`\n : '';\n\n super(`${message}${details}`, options);\n this.name = 'SynchronizationError';\n this.failures = failures;\n }\n}\n"]}
|