Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Contentstack.Core.Tests/ContentTypeTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using Xunit;
using Contentstack.Core.Models;
using Contentstack.Core.Internals;
using System.Threading.Tasks;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
Expand Down Expand Up @@ -143,7 +144,7 @@ public async Task FetchGlobalFieldSchema_NullParameters_Succeeds()
[Fact]
public void GlobalField_EmptyUid_Throws()
{
Assert.Throws<ArgumentNullException>(() => {
Assert.Throws<GlobalFieldException>(() => {
GlobalField globalField = client.GlobalField("");
});
}
Expand Down
7 changes: 3 additions & 4 deletions Contentstack.Core/ContentstackClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public ContentstackClient(IOptions<ContentstackOptions> options)
}
else
{
throw new InvalidOperationException("Add PreviewToken or ManagementToken in LivePreviewConfig");
throw new InvalidOperationException(ErrorMessages.LivePreviewTokenMissing);
}
}
this.SerializerSettings.DateParseHandling = DateParseHandling.None;
Expand Down Expand Up @@ -239,10 +239,9 @@ internal static ContentstackException GetContentstackError(Exception ex)
errorMessage = ex.Message;
}

contentstackError = new ContentstackException()
contentstackError = new ContentstackException(errorMessage)
{
ErrorCode = errorCode,
ErrorMessage = errorMessage,
StatusCode = statusCode,
Errors = errors
};
Expand Down Expand Up @@ -372,7 +371,7 @@ private async Task<JObject> GetLivePreviewData()
}
else
{
throw new InvalidOperationException("Either ManagementToken or PreviewToken is required in LivePreviewConfig");
throw new InvalidOperationException(ErrorMessages.LivePreviewTokenMissing);
}

if (!string.IsNullOrEmpty(this.LivePreviewConfig.ReleaseId))
Expand Down
2 changes: 1 addition & 1 deletion Contentstack.Core/Internals/AssetJsonConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public override Asset ReadJson(JsonReader reader, Type objectType, Asset existin

public override void WriteJson(JsonWriter writer, Asset value, JsonSerializer serializer)
{
throw new NotImplementedException();
throw AssetException.CreateForJsonConversionError();
}
}
}
94 changes: 0 additions & 94 deletions Contentstack.Core/Internals/ContentStackError.cs

This file was deleted.

88 changes: 44 additions & 44 deletions Contentstack.Core/Internals/ContentstackConvert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ public static Int32 ToInt32(object input)
{
output = Convert.ToInt32(input);
}
catch (Exception e)
{
if (e.Source != null)
{
Console.WriteLine("IOException source: {0}", e.Source);
}
catch (Exception e)
{
if (e.Source != null)
{
Console.WriteLine(ErrorMessages.FormatExceptionDetails(e));
}
}

return output;
Expand All @@ -34,12 +34,12 @@ public static bool ToBoolean(object input)
{
output = Convert.ToBoolean(input);
}
catch (Exception e)
{
if (e.Source != null)
{
Console.WriteLine("IOException source: {0}", e.Source);
}
catch (Exception e)
{
if (e.Source != null)
{
Console.WriteLine(ErrorMessages.FormatExceptionDetails(e));
}
}

return output;
Expand All @@ -52,13 +52,13 @@ public static string ToString(object input, string defaultValue = "")
try
{
output = Convert.ToString(input);
}
catch (Exception e)
{
if (e.Source != null)
{
Console.WriteLine("IOException source: {0}", e.Source);
}
}
catch (Exception e)
{
if (e.Source != null)
{
Console.WriteLine(ErrorMessages.FormatExceptionDetails(e));
}
}

return output;
Expand All @@ -76,7 +76,7 @@ public static double ToDouble(object input)
{
if (e.Source != null)
{
Console.WriteLine("IOException source: {0}", e.Source);
Console.WriteLine(ErrorMessages.FormatExceptionDetails(e));
}
}

Expand All @@ -90,15 +90,15 @@ public static decimal ToDecimal(object input)
try
{
output = Convert.ToDecimal(input);
}
catch (Exception e)
{
if (e.Source != null)
{
Console.WriteLine("IOException source: {0}", e.Source);
}
}

}
catch (Exception e)
{
if (e.Source != null)
{
Console.WriteLine(ErrorMessages.FormatExceptionDetails(e));
}
}
return output;
}

Expand All @@ -109,20 +109,20 @@ public static DateTime ToDateTime(object input)
try
{
output = DateTime.Parse(ContentstackConvert.ToString(input));
}
catch (Exception e)
{
if (e.Source != null)
{
Console.WriteLine("IOException source: {0}", e.Source);
}
}

}
catch (Exception e)
{
if (e.Source != null)
{
Console.WriteLine(ErrorMessages.FormatExceptionDetails(e));
}
}
return output;
}

public static string ToISODate(object input)
{
{
DateTime now = DateTime.Now;
try
{
Expand All @@ -132,7 +132,7 @@ public static string ToISODate(object input)
{
if (e.Source != null)
{
Console.WriteLine("IOException source: {0}", e.Source);
Console.WriteLine(ErrorMessages.FormatExceptionDetails(e));
}
}
return now.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'sszzz");
Expand Down Expand Up @@ -186,7 +186,7 @@ public static object GetValue(string value)
{
if (e.Source != null)
{
Console.WriteLine("IOException source: {0}", e.Source);
Console.WriteLine(ErrorMessages.FormatExceptionDetails(e));
}
}

Expand Down Expand Up @@ -222,8 +222,8 @@ public static RegexOptions GetRegexOptions(string option)
return RegexOptions.None;
}
}
}

}
public static Stream GenerateStreamFromString(string s)
{
MemoryStream stream = new MemoryStream();
Expand All @@ -232,7 +232,7 @@ public static Stream GenerateStreamFromString(string s)
writer.Flush();
stream.Position = 0;
return stream;
}
}

#endregion

Expand Down
Loading
Loading