mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-22 17:47:53 +00:00
Add handling of error response from node process
This commit is contained in:
@@ -29,6 +29,11 @@ namespace Microsoft.AspNet.NodeServices {
|
|||||||
var payload = new StringContent(payloadJson, Encoding.UTF8, "application/json");
|
var payload = new StringContent(payloadJson, Encoding.UTF8, "application/json");
|
||||||
var response = await client.PostAsync("http://localhost:" + this._portNumber, payload);
|
var response = await client.PostAsync("http://localhost:" + this._portNumber, payload);
|
||||||
var responseString = await response.Content.ReadAsStringAsync();
|
var responseString = await response.Content.ReadAsStringAsync();
|
||||||
|
|
||||||
|
if (response.StatusCode != HttpStatusCode.OK) {
|
||||||
|
throw new Exception("Node module responded with error: " + responseString);
|
||||||
|
}
|
||||||
|
|
||||||
var responseIsJson = response.Content.Headers.ContentType.MediaType == "application/json";
|
var responseIsJson = response.Content.Headers.ContentType.MediaType == "application/json";
|
||||||
if (responseIsJson) {
|
if (responseIsJson) {
|
||||||
return JsonConvert.DeserializeObject<T>(responseString);
|
return JsonConvert.DeserializeObject<T>(responseString);
|
||||||
|
|||||||
Reference in New Issue
Block a user