MCPcopy Create free account
hub / github.com/getsentry/sentry / tryParseStorage

Function tryParseStorage

static/app/utils/useLocalStorageState.ts:12–18  ·  view source on GitHub ↗
(jsonEncodedValue: string)

Source from the content-addressed store, hash-verified

10// As an improvement, we should maybe allow users to intercept here or possibly use
11// a different parsing function from JSON.parse
12function tryParseStorage(jsonEncodedValue: string): unknown {
13 try {
14 return JSON.parse(jsonEncodedValue);
15 } catch (e) {
16 return null;
17 }
18}
19
20function makeTypeExceptionString(instance: string) {
21 return `useLocalStorage: Native serialization of ${instance} is not supported. You are attempting to serialize a ${instance} instance, this data will be lost. For more info, see how ${instance.toLowerCase()}s are serialized https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#examples`;

Callers 1

initializeStorageFunction · 0.85

Calls 1

parseMethod · 0.45

Tested by

no test coverage detected