UNPKG

sicua

Version:

A tool for analyzing project structure and dependencies

47 lines (46 loc) 1.46 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SerializationUtils = void 0; const analysisUtils_1 = require("../../../utils/common/analysisUtils"); /** * Utilities for serializing error handling analysis objects */ class SerializationUtils { /** * Serializes a fallback element for JSON output */ static serializeFallbackElement(element) { return { element: element.element.getText(), condition: element.condition?.getText(), relatedErrorStates: element.relatedErrorStates, location: element.location, }; } /** * Serializes an error boundary for JSON output */ static serializeErrorBoundary(boundary) { return { library: { ...boundary.library, features: Array.from(boundary.library.features), }, props: boundary.props, location: boundary.location, }; } /** * Verifies that an object can be serialized to JSON * @throws Error if the object contains circular references */ static verifySerializable(object) { try { JSON.stringify(object, analysisUtils_1.replacer); } catch (error) { throw new Error("Analysis result contains circular references that cannot be serialized to JSON"); } } } exports.SerializationUtils = SerializationUtils;