Skip to content

Commit

Permalink
Merge pull request openlayers#373 from bartvde/describelayer
Browse files Browse the repository at this point in the history
add exception handling to WMSDescribeLayer Format (r=@tschaub)
  • Loading branch information
Bart van den Eijnden committed Mar 29, 2012
2 parents d1d5ab9 + 33f8fa0 commit cc68be4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/OpenLayers/Format/WMSDescribeLayer/v1_1.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 12 additions & 0 deletions tests/Format/WMSDescribeLayer.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit cc68be4

Please sign in to comment.