Merge remote-tracking branch 'gravitystorm/history'
[potlatch2.git] / net / systemeD / halcyon / connection / XMLConnection.as
index 74fb3635167fdf7d2e61f4ddea11965a265158d6..6b5d8aeec2fed0af8473c91df9335f208ce4dc1a 100644 (file)
@@ -163,11 +163,19 @@ package net.systemeD.halcyon.connection {
            }
 
         private function changesetCreateComplete(event:Event):void {
-            // response should be a Number changeset id
-            var id:Number = Number(URLLoader(event.target).data);
+            var result:String = URLLoader(event.target).data;
+
+            if (result.match(/^^\d+$/)) {
+                // response should be a Number changeset id
+                var id:Number = Number(URLLoader(event.target).data);
             
-            // which means we now have a new changeset!
-            setActiveChangeset(new Changeset(this, id, lastUploadedChangesetTags));
+                // which means we now have a new changeset!
+                setActiveChangeset(new Changeset(this, id, lastUploadedChangesetTags));
+            } else {
+                var results:XML = XML(result);
+
+                throwServerError(results.message);
+            }
         }
 
         private function changesetCreateError(event:IOErrorEvent):void {
@@ -482,10 +490,15 @@ package net.systemeD.halcyon.connection {
                                function(e:Event):void { 
                        dispatchEvent(new Event(LOAD_COMPLETED));
                                        callback(e);
-                               }, errorOnMapLoad, mapLoadStatus); // needs error handlers
+                               }, errorOnTraceLoad, mapLoadStatus); // needs error handlers
             dispatchEvent(new Event(LOAD_STARTED)); //specifc to map or reusable?
         }
 
+        private function errorOnTraceLoad(event:Event):void {
+            trace("Trace load error");
+            dispatchEvent(new Event(LOAD_COMPLETED));
+               }
+
         /** Fetch the history for the given entity. The callback function will be given an array of entities of that type, representing the different versions */
         override public function fetchHistory(entity:Entity, callback:Function):void {
             if (entity.id >= 0) {