add exception handling to WMSDescribeLayer Format

This commit is contained in:
Bart van den Eijnden
2012-03-29 23:22:31 +02:00
parent d1d5ab9930
commit 33f8fa0aff
2 changed files with 18 additions and 0 deletions

View File

@@ -90,6 +90,12 @@ OpenLayers.Format.WMSDescribeLayer.v1_1 = OpenLayers.Class(
}
describelayer.push({layerName: layerName, owsType: owsType,
owsURL: owsURL, typeName: typeName});
} else if (nodeName == 'ServiceException') {
// an exception must have occurred, so parse it
var parser = new OpenLayers.Format.OGCExceptionReport();
return {
error: parser.read(data)
};
}
}
return describelayer;

View File

@@ -34,6 +34,18 @@
}
function test_read_exception(t) {
t.plan(1);
var text = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' +
'<!DOCTYPE ServiceExceptionReport SYSTEM "http://mapstory.dev.opengeo.org:80/geoserver/schemas/wms/1.1.1/WMS_exception_1_1_1.dtd">' +
'<ServiceExceptionReport version="1.1.1" > <ServiceException code="LayerNotDefined" locator="MapLayerInfoKvpParser">' +
'geonode:_map_107_annotations: no such layer on this server' +
'</ServiceException></ServiceExceptionReport>';
var format = new OpenLayers.Format.WMSDescribeLayer();
var obj = format.read(text);
t.ok(!!obj.error, "Error reported correctly");
}
</script>
</head>
<body>