Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
8 changes: 4 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 @@ -338,7 +338,7 @@ public async Task<IList> GetContentTypes(Dictionary<string, object> param = null
}
catch (Exception ex)
{
throw GetContentstackError(ex);
throw new GetContentstackError(string.Format(ErrorMessages.ContentstackClientRequestError, ex.Message), ex);
}
}

Expand Down Expand Up @@ -372,7 +372,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 Expand Up @@ -873,7 +873,7 @@ private async Task<SyncStack> GetResultAsync(string Init = "false", SyncType Syn
}
catch (Exception ex)
{
throw GetContentstackError(ex);
throw new GetContentstackError(string.Format(ErrorMessages.ContentstackSyncRequestError, ex.Message), ex);
}
}
#endregion
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();
}
}
}
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