Skip to content

Commit cc19e87

Browse files
committed
Handle invalid token
If the token is invalid and the user cannot be authorized then swallong the unauthorized exception will lead to a null reference error. By exposing the HttpRequestException the application will know that the user was unauthorized. Fixes: CMS-40534
1 parent 739a1c5 commit cc19e87

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

APIs/src/EpiServer.ContentGraph/Api/Querying/GraphQueryBuilder.cs

+6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using EPiServer.ContentGraph.Helpers.Text;
1313
using EPiServer.ContentGraph.Helpers;
1414
using EPiServer.ContentGraph.Tracing;
15+
using System.Net;
1516

1617
namespace EPiServer.ContentGraph.Api.Querying
1718
{
@@ -228,6 +229,11 @@ public async Task<ContentGraphResult> GetResultAsync()
228229
}
229230
catch (HttpRequestException e)
230231
{
232+
if (e.StatusCode == HttpStatusCode.Unauthorized)
233+
{
234+
throw e;
235+
}
236+
231237
try
232238
{
233239
return JsonConvert.DeserializeObject<ContentGraphResult>(e.Message);

0 commit comments

Comments
 (0)