From f6bb28a71dd45505c6ceb15826473c9f1f237737 Mon Sep 17 00:00:00 2001 From: Greg Beaty Date: Wed, 9 Dec 2015 16:40:04 -0500 Subject: [PATCH] Add handling of error response from node process --- .../HostingModels/HttpNodeInstance.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Microsoft.AspNet.NodeServices/HostingModels/HttpNodeInstance.cs b/Microsoft.AspNet.NodeServices/HostingModels/HttpNodeInstance.cs index b863ad1..6707527 100644 --- a/Microsoft.AspNet.NodeServices/HostingModels/HttpNodeInstance.cs +++ b/Microsoft.AspNet.NodeServices/HostingModels/HttpNodeInstance.cs @@ -29,6 +29,11 @@ namespace Microsoft.AspNet.NodeServices { var payload = new StringContent(payloadJson, Encoding.UTF8, "application/json"); var response = await client.PostAsync("http://localhost:" + this._portNumber, payload); 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"; if (responseIsJson) { return JsonConvert.DeserializeObject(responseString);