error handling in WFSDescribeFeatureType format

This commit is contained in:
Bart van den Eijnden
2012-03-30 23:04:03 +02:00
parent 9a5364f309
commit 2e83863e90
2 changed files with 23 additions and 2 deletions

View File

@@ -5,6 +5,7 @@
/**
* @requires OpenLayers/Format/XML.js
* @requires OpenLayers/Format/OGCExceptionReport.js
*/
/**
@@ -188,7 +189,11 @@ OpenLayers.Format.WFSDescribeFeatureType = OpenLayers.Class(
}
var schema = {};
this.readNode(data, schema);
if (schema.version === undefined) {
// an exception must have occurred, so parse it
var parser = new OpenLayers.Format.OGCExceptionReport();
schema.error = parser.read(data);
}
return schema;
},

View File

@@ -374,8 +374,24 @@
// GeoServer example above
}
function test_read_exception(t) {
t.plan(1);
var text =
'<?xml version="1.0" encoding="UTF-8"?>' +
'<ows:ExceptionReport version="1.0.0"' +
' xsi:schemaLocation="http://www.opengis.net/ows http://localhost:8080/geoserver/schemas/ows/1.0.0/owsExceptionReport.xsd"' +
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ows="http://www.opengis.net/ows">' +
' <ows:Exception exceptionCode="NoApplicableCode">' +
' <ows:ExceptionText>Could not find type: {http://geonode.org/}_map_4_annotations</ows:ExceptionText>' +
' </ows:Exception>' +
'</ows:ExceptionReport>';
var format = new OpenLayers.Format.WFSDescribeFeatureType();
var obj = format.read(text);
t.ok(!!obj.error, "Error reported correctly");
}
</script>
</head>
<body>
</body>
</html>
</html>