-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
using Moesif.Api.Exceptions; | ||
using System.IO; | ||
using System.Text; | ||
using Newtonsoft.Json.Linq; | ||
|
||
namespace Moesif.Api.Controllers | ||
{ | ||
|
@@ -62,7 +63,9 @@ internal void ValidateResponse(HttpResponse _response, HttpContext _context) | |
Byte[] bytes = new byte[body.Length]; | ||
body.Position = 0; | ||
body.Read(bytes, 0, (int)body.Length); | ||
bodyData = Encoding.ASCII.GetString(bytes); | ||
string bodyStr = Encoding.UTF8.GetString(bytes); | ||
JObject jsonErr = JObject.Parse(bodyStr); | ||
bodyData = (string)jsonErr["moesif_error"]["msg"]; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
HzANut
Author
Contributor
|
||
} | ||
} | ||
catch (Exception) { }; | ||
|
@XinyuLuan in some error case/statuses.. it is possible that the body is not json (because moesif api may not even reach it).. in that case, json parsing will throw an exception and the exception will be silently absorbed below.. in line
71
?maybe we want to return the non-json body if we cannot extract
["moesif_error"]["msg"]
?