Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ public async Task Find_Terms_WithLocaleAndFallback_ReturnsTerms()
LogAssert("Verifying response");
Assert.NotNull(result);
Assert.NotNull(result.Items);
// Fallback means we should get at least as many terms as without fallback
Assert.True(result.Items.Any());
}

Expand Down
11 changes: 8 additions & 3 deletions Contentstack.Core/Models/Taxonomy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
}
}
#endregion
public ContentstackClient Stack

Check warning on line 41 in Contentstack.Core/Models/Taxonomy.cs

View workflow job for this annotation

GitHub Actions / unit-test

'Taxonomy.Stack' hides inherited member 'Query.Stack'. Use the new keyword if hiding was intended.

Check warning on line 41 in Contentstack.Core/Models/Taxonomy.cs

View workflow job for this annotation

GitHub Actions / unit-test

'Taxonomy.Stack' hides inherited member 'Query.Stack'. Use the new keyword if hiding was intended.

Check warning on line 41 in Contentstack.Core/Models/Taxonomy.cs

View workflow job for this annotation

GitHub Actions / unit-test

'Taxonomy.Stack' hides inherited member 'Query.Stack'. Use the new keyword if hiding was intended.

Check warning on line 41 in Contentstack.Core/Models/Taxonomy.cs

View workflow job for this annotation

GitHub Actions / unit-test

'Taxonomy.Stack' hides inherited member 'Query.Stack'. Use the new keyword if hiding was intended.

Check warning on line 41 in Contentstack.Core/Models/Taxonomy.cs

View workflow job for this annotation

GitHub Actions / unit-test

'Taxonomy.Stack' hides inherited member 'Query.Stack'. Use the new keyword if hiding was intended.

Check warning on line 41 in Contentstack.Core/Models/Taxonomy.cs

View workflow job for this annotation

GitHub Actions / unit-test

'Taxonomy.Stack' hides inherited member 'Query.Stack'. Use the new keyword if hiding was intended.
{
get;
set;
Expand Down Expand Up @@ -126,10 +126,9 @@
mainJson["locale"] = locale;

var handler = new HttpRequestHandler(Stack);
var branch = Stack.Config?.Branch ?? "main";
var result = await handler.ProcessRequest(
_Url, headerAll, mainJson,
Branch: branch,
Branch: Stack.Config.Branch,
timeout: Stack.Config.Timeout,
proxy: Stack.Config.Proxy
);
Expand All @@ -142,7 +141,13 @@
}
catch (Exception ex)
{
throw TaxonomyException.CreateForProcessingError(ex);
var contentstackError = GetContentstackError(ex);
throw new TaxonomyException(contentstackError.Message, ex)
{
ErrorCode = contentstackError.ErrorCode,
StatusCode = contentstackError.StatusCode,
Errors = contentstackError.Errors
};
}
}

Expand Down Expand Up @@ -341,7 +346,7 @@
return _StackHeaders;
}
}
internal static ContentstackException GetContentstackError(Exception ex)

Check warning on line 349 in Contentstack.Core/Models/Taxonomy.cs

View workflow job for this annotation

GitHub Actions / unit-test

'Taxonomy.GetContentstackError(Exception)' hides inherited member 'Query.GetContentstackError(Exception)'. Use the new keyword if hiding was intended.

Check warning on line 349 in Contentstack.Core/Models/Taxonomy.cs

View workflow job for this annotation

GitHub Actions / unit-test

'Taxonomy.GetContentstackError(Exception)' hides inherited member 'Query.GetContentstackError(Exception)'. Use the new keyword if hiding was intended.

Check warning on line 349 in Contentstack.Core/Models/Taxonomy.cs

View workflow job for this annotation

GitHub Actions / unit-test

'Taxonomy.GetContentstackError(Exception)' hides inherited member 'Query.GetContentstackError(Exception)'. Use the new keyword if hiding was intended.

Check warning on line 349 in Contentstack.Core/Models/Taxonomy.cs

View workflow job for this annotation

GitHub Actions / unit-test

'Taxonomy.GetContentstackError(Exception)' hides inherited member 'Query.GetContentstackError(Exception)'. Use the new keyword if hiding was intended.

Check warning on line 349 in Contentstack.Core/Models/Taxonomy.cs

View workflow job for this annotation

GitHub Actions / unit-test

'Taxonomy.GetContentstackError(Exception)' hides inherited member 'Query.GetContentstackError(Exception)'. Use the new keyword if hiding was intended.
{
Int32 errorCode = 0;
string errorMessage = string.Empty;
Expand Down
35 changes: 29 additions & 6 deletions Contentstack.Core/Models/Term.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,13 @@ public async Task<T> Fetch<T>(string locale = null)
}
catch (Exception ex)
{
throw TaxonomyException.CreateForProcessingError(ex);
var contentstackError = Taxonomy.GetContentstackError(ex);
throw new TaxonomyException(contentstackError.Message, ex)
{
ErrorCode = contentstackError.ErrorCode,
StatusCode = contentstackError.StatusCode,
Errors = contentstackError.Errors
};
}
}

Expand Down Expand Up @@ -91,7 +97,13 @@ public async Task<T> Locales<T>()
}
catch (Exception ex)
{
throw TaxonomyException.CreateForProcessingError(ex);
var contentstackError = Taxonomy.GetContentstackError(ex);
throw new TaxonomyException(contentstackError.Message, ex)
{
ErrorCode = contentstackError.ErrorCode,
StatusCode = contentstackError.StatusCode,
Errors = contentstackError.Errors
};
}
}

Expand Down Expand Up @@ -122,7 +134,13 @@ public async Task<T> Ancestors<T>()
}
catch (Exception ex)
{
throw TaxonomyException.CreateForProcessingError(ex);
var contentstackError = Taxonomy.GetContentstackError(ex);
throw new TaxonomyException(contentstackError.Message, ex)
{
ErrorCode = contentstackError.ErrorCode,
StatusCode = contentstackError.StatusCode,
Errors = contentstackError.Errors
};
}
}

Expand Down Expand Up @@ -153,7 +171,13 @@ public async Task<T> Descendants<T>()
}
catch (Exception ex)
{
throw TaxonomyException.CreateForProcessingError(ex);
var contentstackError = Taxonomy.GetContentstackError(ex);
throw new TaxonomyException(contentstackError.Message, ex)
{
ErrorCode = contentstackError.ErrorCode,
StatusCode = contentstackError.StatusCode,
Errors = contentstackError.Errors
};
}
}

Expand All @@ -172,10 +196,9 @@ private async Task<string> ExecuteRequest(string url, Dictionary<string, object>
mainJson[param.Key] = param.Value;

var handler = new HttpRequestHandler(_stack);
var branch = _stack.Config?.Branch ?? "main";
return await handler.ProcessRequest(
url, headerAll, mainJson,
Branch: branch,
Branch: _stack.Config.Branch,
timeout: _stack.Config.Timeout,
proxy: _stack.Config.Proxy
);
Expand Down
14 changes: 10 additions & 4 deletions Contentstack.Core/Models/TermQuery.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Contentstack.Core.Internals;
using Newtonsoft.Json.Linq;
Expand Down Expand Up @@ -87,18 +88,17 @@ public async Task<ContentstackCollection<T>> Find<T>()
mainJson[param.Key] = param.Value;

var handler = new HttpRequestHandler(_stack);
var branch = _stack.Config?.Branch ?? "main";
var result = await handler.ProcessRequest(
Url, headerAll, mainJson,
Branch: branch,
Branch: _stack.Config.Branch,
timeout: _stack.Config.Timeout,
proxy: _stack.Config.Proxy
);

var jObject = JObject.Parse(result);
var terms = jObject.SelectToken("$.terms")?.ToObject<IEnumerable<T>>(_stack.Serializer);
var collection = jObject.ToObject<ContentstackCollection<T>>(_stack.Serializer);
collection.Items = terms ?? new List<T>();
collection.Items = terms ?? Enumerable.Empty<T>();
return collection;
}
catch (TaxonomyException)
Expand All @@ -107,7 +107,13 @@ public async Task<ContentstackCollection<T>> Find<T>()
}
catch (Exception ex)
{
throw TaxonomyException.CreateForProcessingError(ex);
var contentstackError = Taxonomy.GetContentstackError(ex);
throw new TaxonomyException(contentstackError.Message, ex)
{
ErrorCode = contentstackError.ErrorCode,
StatusCode = contentstackError.StatusCode,
Errors = contentstackError.Errors
};
}
}
}
Expand Down
Loading