From 3b8e272a112120552d383c0d68595386efae148c Mon Sep 17 00:00:00 2001 From: Bart van den Eijnden Date: Wed, 22 Apr 2015 11:57:33 +0200 Subject: [PATCH] Better error handling in the ArcGIS REST vector examples --- examples/vector-esri-edit.js | 17 +++++++++++------ examples/vector-esri.js | 17 +++++++++++------ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/examples/vector-esri-edit.js b/examples/vector-esri-edit.js index 1647246fc9..5ebb58bf7f 100644 --- a/examples/vector-esri-edit.js +++ b/examples/vector-esri-edit.js @@ -31,12 +31,17 @@ var vectorSource = new ol.source.Vector({ '&geometryType=esriGeometryEnvelope&inSR=102100&outFields=*' + '&outSR=102100'; $.ajax({url: url, dataType: 'jsonp', success: function(response) { - // dataProjection will be read from document - var features = esrijsonFormat.readFeatures(response, { - featureProjection: projection - }); - if (features.length > 0) { - vectorSource.addFeatures(features); + if (response.error) { + alert(response.error.message + '\n' + + response.error.details.join('\n')); + } else { + // dataProjection will be read from document + var features = esrijsonFormat.readFeatures(response, { + featureProjection: projection + }); + if (features.length > 0) { + vectorSource.addFeatures(features); + } } }}); }, diff --git a/examples/vector-esri.js b/examples/vector-esri.js index 2cacb97269..0ba8581813 100644 --- a/examples/vector-esri.js +++ b/examples/vector-esri.js @@ -77,12 +77,17 @@ var vectorSource = new ol.source.Vector({ '&geometryType=esriGeometryEnvelope&inSR=102100&outFields=*' + '&outSR=102100'; $.ajax({url: url, dataType: 'jsonp', success: function(response) { - // dataProjection will be read from document - var features = esrijsonFormat.readFeatures(response, { - featureProjection: projection - }); - if (features.length > 0) { - vectorSource.addFeatures(features); + if (response.error) { + alert(response.error.message + '\n' + + response.error.details.join('\n')); + } else { + // dataProjection will be read from document + var features = esrijsonFormat.readFeatures(response, { + featureProjection: projection + }); + if (features.length > 0) { + vectorSource.addFeatures(features); + } } }}); },