diff --git a/lib/OpenLayers/Format/WFSDescribeFeatureType.js b/lib/OpenLayers/Format/WFSDescribeFeatureType.js index 697035a595..a946da060c 100644 --- a/lib/OpenLayers/Format/WFSDescribeFeatureType.js +++ b/lib/OpenLayers/Format/WFSDescribeFeatureType.js @@ -5,6 +5,7 @@ /** * @requires OpenLayers/Format/XML.js + * @requires OpenLayers/Format/OGCExceptionReport.js */ /** @@ -187,8 +188,13 @@ OpenLayers.Format.WFSDescribeFeatureType = OpenLayers.Class( data = data.documentElement; } var schema = {}; - this.readNode(data, schema); - + if (data.nodeName.split(":").pop() === 'ExceptionReport') { + // an exception must have occurred, so parse it + var parser = new OpenLayers.Format.OGCExceptionReport(); + schema.error = parser.read(data); + } else { + this.readNode(data, schema); + } return schema; }, diff --git a/tests/Format/WFSDescribeFeatureType.html b/tests/Format/WFSDescribeFeatureType.html index 53faa5d584..820ed3d910 100644 --- a/tests/Format/WFSDescribeFeatureType.html +++ b/tests/Format/WFSDescribeFeatureType.html @@ -374,8 +374,24 @@ // GeoServer example above } + function test_read_exception(t) { + t.plan(1); + var text = + '' + + '' + + ' ' + + ' Could not find type: {http://geonode.org/}_map_4_annotations' + + ' ' + + ''; + var format = new OpenLayers.Format.WFSDescribeFeatureType(); + var obj = format.read(text); + t.ok(!!obj.error, "Error reported correctly"); + } + - \ No newline at end of file +