Merge pull request #31 from gravitystorm/errors
authorRichard Fairhurst <richard@systemeD.net>
Sun, 4 Mar 2012 14:27:57 +0000 (06:27 -0800)
committerRichard Fairhurst <richard@systemeD.net>
Sun, 4 Mar 2012 14:27:57 +0000 (06:27 -0800)
Errors

net/systemeD/halcyon/connection/XMLConnection.as
potlatch2.mxml

index 8f1172bf4a35c09265c36ebd295ba441f6a36966..fc046c251964e5f29d618aac1b056a6e838d21d6 100644 (file)
@@ -74,18 +74,23 @@ package net.systemeD.halcyon.connection {
 
                private function sendLoadRequest(request:URLRequest):void {
                        var mapLoader:URLLoader = new URLLoader();
+            var errorHandler:Function = function(event:IOErrorEvent):void {
+                errorOnMapLoad(event, request);
+            }
                        mapLoader.addEventListener(Event.COMPLETE, loadedMap);
-                       mapLoader.addEventListener(IOErrorEvent.IO_ERROR, errorOnMapLoad);
+                       mapLoader.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
                        mapLoader.addEventListener(HTTPStatusEvent.HTTP_STATUS, mapLoadStatus);
             request.requestHeaders.push(new URLRequestHeader("X-Error-Format", "XML"));
                        mapLoader.load(request);
                        dispatchEvent(new Event(LOAD_STARTED));
                }
 
-        private function errorOnMapLoad(event:Event):void {
-                       dispatchEvent(new MapEvent(MapEvent.ERROR, { message: "Couldn't load the map" } ));
-                       dispatchEvent(new Event(LOAD_COMPLETED));
+        private function errorOnMapLoad(event:Event, request:URLRequest):void {
+            var url:String = request.url + '?' + URLVariables(request.data).toString(); // for get reqeusts, at least
+            dispatchEvent(new MapEvent(MapEvent.ERROR, { message: "There was a problem loading the map data.\nPlease check your internet connection, or try zooming in.\n\n" + url } ));
+            dispatchEvent(new Event(LOAD_COMPLETED));
         }
+
         private function mapLoadStatus(event:HTTPStatusEvent):void {
         }
 
index b365c7ddc692b7ac48f050e8b43252a79fb65f7d..279d08f947299aeaa363d48fbe8c78aeaeaab0aa 100644 (file)
                
                public function onMapError(mapEvent:MapEvent):void {
                        var buttons:uint=0;
-                       if (mapEvent.params.no) { trace("no is set"); }
                        if (mapEvent.params.yes             ) buttons|=mx.controls.Alert.YES;
                        if (mapEvent.params.no              ) buttons|=mx.controls.Alert.NO;
                        if (mapEvent.params.cancel          ) buttons|=mx.controls.Alert.CANCEL;
                        if (mapEvent.params.ok || buttons==0) buttons|=mx.controls.Alert.OK;
-                       trace("showing alert with "+buttons);
                        Alert.show(mapEvent.params.message, 'Error', buttons, null, function(closeEvent:CloseEvent):void { 
                                switch (closeEvent.detail) {
                                        case mx.controls.Alert.CANCEL:  mapEvent.params.cancel(); break; //fixme? this gets called if user presses escape, even if there's no cancel button.