I'm struggling to find the proper way to handle errors in a QueryTask. Particularly if the user clicks outside the feature layer.
My current QueryTask looks at a field (bare_earth) populated with either a 1 or a 0. I thought if I used...
if (bare_earth === 0) {
do X;
}
else if (bare_earth === 1) {
do y;
}
else{
error handling;
}
However, clicks outside the feature layer return the following error:
TypeError {stack: "TypeError: Cannot read property 'attributes' of un… at c (http://js.arcgis.com/3.9/init.js:74:436)", message: "Cannot read property 'attributes' of undefined"}
"TypeError: Cannot read property 'attributes' of undefined
Makes sense, since there are no attributes for the undefined area. That being said, how do I go about handling this?
For frame of reference, each of my three potential outcomes (1, 0, no data) alter the value of a variable (result) that is used to populate a DIV. For example, I want clicks outside of the feature to populate the DIV with "...outside the area...".
Thanks!