Skip to content

Commit

Permalink
Merge pull request #261 from contentstack/patch-fix-add-catch
Browse files Browse the repository at this point in the history
Add: Try catch to getFieldVariantStatus
  • Loading branch information
hiteshshetty-dev authored Oct 8, 2024
2 parents de4e492 + e956f32 commit a34bea9
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/visualBuilder/components/FieldRevert/FieldRevertComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,18 @@ export const BASE_VARIANT_STATUS: IVariantStatus = {
fieldLevelCustomizations: false,
};

export async function getFieldVariantStatus(fieldPathWithIndex: string) {
const result = await visualBuilderPostMessage?.send<IVariantStatus>(
"get-field-variant-status",
fieldPathWithIndex
);
return result;
export async function getFieldVariantStatus(
fieldPathWithIndex: string
): Promise<IVariantStatus | undefined> {
try {
const result = await visualBuilderPostMessage?.send<IVariantStatus>(
"get-field-variant-status",
fieldPathWithIndex
);
return result;
} catch (error) {
console.error("Failed to get field variant status:", error);
}
}

export const FieldRevertComponent = ({
Expand Down

0 comments on commit a34bea9

Please sign in to comment.