From 99260e10b8bf0c29c1bf24c92e3a45199c358830 Mon Sep 17 00:00:00 2001 From: reeshika-h Date: Tue, 25 Nov 2025 15:38:20 +0530 Subject: [PATCH 1/3] Centralize error messages in Constants/ErrorMessages.cs - Created new ErrorMessages.cs constants file for centralized error message management - Updated RTEJsonConverter.cs to use error message constant instead of hardcoded string - Added Constants folder to project file - Improves maintainability by keeping all error messages in one location --- Contentstack.Utils/Constants/ErrorMessages.cs | 11 +++++++++++ Contentstack.Utils/Contentstack.Utils.csproj | 1 + Contentstack.Utils/Converters/RTEJsonConverter.cs | 3 ++- 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 Contentstack.Utils/Constants/ErrorMessages.cs diff --git a/Contentstack.Utils/Constants/ErrorMessages.cs b/Contentstack.Utils/Constants/ErrorMessages.cs new file mode 100644 index 0000000..6b1de14 --- /dev/null +++ b/Contentstack.Utils/Constants/ErrorMessages.cs @@ -0,0 +1,11 @@ +namespace Contentstack.Utils.Constants +{ + /// + /// Centralized error messages for the Contentstack Utils library + /// + public static class ErrorMessages + { + public const string InvalidRteJson = "Invalid RTE JSON. Provide a valid JSON structure and try again."; + } +} + diff --git a/Contentstack.Utils/Contentstack.Utils.csproj b/Contentstack.Utils/Contentstack.Utils.csproj index b01be4c..6eaeb87 100644 --- a/Contentstack.Utils/Contentstack.Utils.csproj +++ b/Contentstack.Utils/Contentstack.Utils.csproj @@ -36,6 +36,7 @@ + diff --git a/Contentstack.Utils/Converters/RTEJsonConverter.cs b/Contentstack.Utils/Converters/RTEJsonConverter.cs index 57323be..ecc198b 100644 --- a/Contentstack.Utils/Converters/RTEJsonConverter.cs +++ b/Contentstack.Utils/Converters/RTEJsonConverter.cs @@ -3,6 +3,7 @@ using System.Reflection; using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using Contentstack.Utils.Constants; namespace Contentstack.Utils.Converters { @@ -10,7 +11,7 @@ public class RTEJsonConverter : JsonConverter { public override bool CanConvert(Type objectType) { - throw new NotImplementedException(); + throw new InvalidOperationException(ErrorMessages.InvalidRteJson); } public override object ReadJson(JsonReader reader, Type objectType, From 349e285e1fb815e693157031da8d4166c74cbfc5 Mon Sep 17 00:00:00 2001 From: reeshika-h Date: Tue, 25 Nov 2025 15:52:14 +0530 Subject: [PATCH 2/3] fixed testcases --- Contentstack.Utils.Tests/DefaultRenderTest.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Contentstack.Utils.Tests/DefaultRenderTest.cs b/Contentstack.Utils.Tests/DefaultRenderTest.cs index a13bd5b..6f44ee3 100644 --- a/Contentstack.Utils.Tests/DefaultRenderTest.cs +++ b/Contentstack.Utils.Tests/DefaultRenderTest.cs @@ -178,7 +178,11 @@ public void testLinkhDocument() string result = defaultRender.RenderNode("a", nodeLink, (nodes) => { return text; }); - Assert.Equal($"Text To set Link", result); + string url = nodeLink.attrs.ContainsKey("url") ? (string)nodeLink.attrs["url"] : ""; + string target = nodeLink.attrs.ContainsKey("target") ? (string)nodeLink.attrs["target"] : ""; + string title = nodeLink.attrs.ContainsKey("title") ? (string)nodeLink.attrs["title"] : ""; + + Assert.Equal($"Text To set Link", result); } [Fact] From d45c08839a8c9377afaaec632ba6e8ad47dc99d4 Mon Sep 17 00:00:00 2001 From: reeshika-h Date: Wed, 7 Jan 2026 17:11:01 +0530 Subject: [PATCH 3/3] Update version to 1.0.7 and improve error messages in CHANGELOG. Update copyright year in LICENSE. --- CHANGELOG.md | 4 ++++ Contentstack.Utils.sln | 2 +- Directory.Build.props | 2 +- LICENSE | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ac3b4b8..a265a5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +### Version: 1.0.7 +#### Date: January-12-2026 +- Improved error messages + ### Version: 1.0.6 #### Date: June-09-2025 - Used 'title' and 'target' in a tags diff --git a/Contentstack.Utils.sln b/Contentstack.Utils.sln index 382b162..c0f18fa 100644 --- a/Contentstack.Utils.sln +++ b/Contentstack.Utils.sln @@ -21,7 +21,7 @@ Global {EB2B5E23-E45F-4C6C-BF98-FE3971DE4250}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution - version = 1.0.6 + version = 1.0.7 Policies = $0 $0.DotNetNamingPolicy = $1 $1.DirectoryNamespaceAssociation = PrefixedHierarchical diff --git a/Directory.Build.props b/Directory.Build.props index 2a251d5..9a2bf6c 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,5 +1,5 @@ - 1.0.6 + 1.0.7 diff --git a/LICENSE b/LICENSE index 501f936..4382a0d 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright © 2012-2025 Contentstack. All Rights Reserved +Copyright © 2012-2026 Contentstack. All Rights Reserved Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal