Merge pull request #378 from bartvde/wfsdft
error handling in WFSDescribeFeatureType format (r=@ahocevar,elemoine)
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @requires OpenLayers/Format/XML.js
|
* @requires OpenLayers/Format/XML.js
|
||||||
|
* @requires OpenLayers/Format/OGCExceptionReport.js
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -187,8 +188,13 @@ OpenLayers.Format.WFSDescribeFeatureType = OpenLayers.Class(
|
|||||||
data = data.documentElement;
|
data = data.documentElement;
|
||||||
}
|
}
|
||||||
var schema = {};
|
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;
|
return schema;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -374,8 +374,24 @@
|
|||||||
// GeoServer example above
|
// 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>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user