mirror of https://github.com/ArduPilot/ardupilot
Planner: Added try catch around web request in the parser to prevent blowing up.
This commit is contained in:
parent
03094a91b6
commit
75cb93ada7
|
@ -37,7 +37,7 @@ namespace ArdupilotMega.Utilities
|
|||
foreach (string parameterLocation in parameterLocations)
|
||||
{
|
||||
// Write the start element for this parameter location
|
||||
objXmlTextWriter.WriteStartElement(parameterLocation);
|
||||
objXmlTextWriter.WriteStartElement(parameterLocation.ToLower().Contains("arducopter") ? MainV2.Firmwares.ArduCopter2.ToString() : MainV2.Firmwares.ArduPlane.ToString());
|
||||
|
||||
// Read and parse the content.
|
||||
string dataFromAddress = ReadDataFromAddress(parameterLocation);
|
||||
|
@ -273,6 +273,9 @@ namespace ArdupilotMega.Utilities
|
|||
|
||||
log.Info(address);
|
||||
|
||||
// Make sure we don't blow up if the user is not connected or the endpoint is not available
|
||||
try
|
||||
{
|
||||
var request = WebRequest.Create(address);
|
||||
|
||||
// Plenty of timeout
|
||||
|
@ -285,7 +288,7 @@ namespace ArdupilotMega.Utilities
|
|||
using (var response = request.GetResponse())
|
||||
{
|
||||
// Display the status.
|
||||
log.Info(((HttpWebResponse) response).StatusDescription);
|
||||
log.Info(((HttpWebResponse)response).StatusDescription);
|
||||
|
||||
// Get the stream containing content returned by the server.
|
||||
using (var dataStream = response.GetResponseStream())
|
||||
|
@ -314,5 +317,11 @@ namespace ArdupilotMega.Utilities
|
|||
// Return the data
|
||||
return data;
|
||||
}
|
||||
catch (WebException ex)
|
||||
{
|
||||
log.Error(String.Format("The request to {0} failed.", address), ex);
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue