From a5069bd27b06c39704fbfbd3ea89601adb27dedb Mon Sep 17 00:00:00 2001 From: dmfenton Date: Tue, 10 Nov 2015 19:38:29 -0500 Subject: [PATCH] fix 3 unhandled exceptions in lib/geojson --- CHANGELOG.md | 4 ++++ lib/GeoJSON.js | 14 +++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b51952711..38e57bfb8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## Unreleased +### Fixed +* Remove 3 causes of unhandled exceptions in lib/geojson + ## [2.10.2] - 2015-11-10 ### Fixed * Clean up file on local disk after single page export diff --git a/lib/GeoJSON.js b/lib/GeoJSON.js index bb7bcf0a1..49e031c20 100644 --- a/lib/GeoJSON.js +++ b/lib/GeoJSON.js @@ -97,7 +97,11 @@ function transformFeature (feature, fields) { // convert attribute expects an actual object and not just the values var attr = {} attr[name] = feature.attributes[name] - attributes[fields[name].outName] = convertAttribute(attr, fields[name]) + try { + attributes[fields[name].outName] = convertAttribute(attr, fields[name]) + } catch (e) { + console.error('Field was missing from attribute') + } }) } @@ -164,10 +168,14 @@ function convertAttribute (attribute, field) { var inValue = attribute[field.name] var value if (inValue === null) return inValue - if (field.domain) { + if (field.domain && field.domain.type === 'codedValue') { value = cvd(inValue, field) } else if (field.type === 'esriFieldTypeDate') { - value = new Date(inValue).toISOString() + try { + value = new Date(inValue).toISOString() + } catch (e) { + value = inValue + } } else { value = inValue }