Dolor3v-ai / src /utils /parseJson.ts
Dolor D Prince
deploy: dolor3v gateway v1.0
c7052c4
Raw
History Blame Contribute Delete
513 Bytes
import { addBreadcrumb } from '@sentry/node-core/light';
type SerializableValue =
| boolean
| null
| number
| string
| undefined
| readonly SerializableValue[]
| { readonly [key: string]: SerializableValue };
export const parseJson = <T = SerializableValue>(subject: string): T => {
try {
return JSON.parse(subject);
} catch (error) {
addBreadcrumb({
data: {
subject,
},
level: 'debug',
message: 'could not parse JSON',
});
throw error;
}
};