]> git.mxchange.org Git - flightgear.git/commitdiff
Catch exceptions when no metar data is available (e.g. KUFO)
authorehofman <ehofman>
Sat, 21 Feb 2004 15:00:49 +0000 (15:00 +0000)
committerehofman <ehofman>
Sat, 21 Feb 2004 15:00:49 +0000 (15:00 +0000)
src/Environment/environment_ctrl.cxx

index 2f08e98280beb424af96603dee34f96267f0e74f..0e0d4dc2cd5ec9f95d85fecc5a97c1ec9e8855ca 100644 (file)
@@ -25,6 +25,8 @@
 #include <stdlib.h>
 #include <algorithm>
 
+#include <simgear/structure/exception.hxx>
+
 #include <Main/fg_props.hxx>
 
 #include "environment_mgr.hxx"
@@ -412,7 +414,15 @@ FGMetarEnvironmentCtrl::fetch_data (const char *icao)
 
         _icao = strdup(icao);
     }
-    SGMetar *m = new SGMetar(_icao);
+
+    SGMetar *m;
+    try {
+        m = new SGMetar(_icao);
+    } catch (const sg_io_exception& e) {
+        SG_LOG( SG_GENERAL, SG_WARN, "Error fetching live weather data: "
+                                      << e.getFormattedMessage().c_str() );
+        return;
+    }
 
     d = m->getMinVisibility().getVisibility_m();
     d = (d != SGMetarNaN) ? d : 10000;