diff options
author | Struan Donald <struan@exo.org.uk> | 2014-04-02 16:43:47 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2014-04-02 16:43:47 +0100 |
commit | 84ba5e78c872681e735f8f0e6a3cd12380892e45 (patch) | |
tree | a7cc570007827797c9e5eed9965750496b331655 | |
parent | 0bcbd779222f31c8115009a73ba6e1d70ade28c6 (diff) |
add error classification to locate error objects
So we can work out what sort of error we've got and act accrodingly
rather than just blindly displaying a message
-rw-r--r-- | src/js/locate.js | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/js/locate.js b/src/js/locate.js index 9d631f6..c300d78 100644 --- a/src/js/locate.js +++ b/src/js/locate.js @@ -7,7 +7,7 @@ lookup: function(q) { var that = this; if (!q) { - this.trigger('search_failed', { msg: FMS.strings.missing_location } ); + this.trigger('search_failed', { msg: FMS.strings.missing_location, err: 'missing_location' } ); return false; } @@ -24,14 +24,14 @@ } else if ( data.suggestions ) { that.trigger( 'search_failed', { suggestions: data.suggestions, locations: data.locations } ); } else { - that.trigger( 'search_failed', { msg: data.error } ); + that.trigger( 'search_failed', { msg: data.error, err: 'data_error' } ); } } else { - that.trigger( 'search_failed', { msg: FMS.strings.location_problem } ); + that.trigger( 'search_failed', { msg: FMS.strings.location_problem, err: 'location_problem' } ); } }, error: function(data, status, errorThrown) { - that.trigger( 'search_failed', { msg: FMS.strings.location_problem } ); + that.trigger( 'search_failed', { msg: FMS.strings.location_problem, err: 'location_problem' } ); } } ); }, @@ -68,7 +68,7 @@ if ( err && err.code == PositionError.PERMISSION_DENIED ) { errorMsg = FMS.strings.geolocation_denied; } - that.trigger('gps_failed', { msg: errorMsg } ); + that.trigger('gps_failed', { msg: errorMsg, err: 'gps_failed' } ); }, { timeout: 20000, enableHighAccuracy: true } ); @@ -110,13 +110,13 @@ timeout: 10000, success: function(data) { if (data.error) { - that.trigger('gps_failed', { msg: data.error } ); + that.trigger('gps_failed', { msg: data.error, err: 'data_error' } ); return; } that.trigger('gps_located', { coordinates: coords, details: data } ); }, error: function (data, status, errorThrown) { - that.trigger('gps_failed', { msg: FMS.strings.location_check_failed } ); + that.trigger('gps_failed', { msg: FMS.strings.location_check_failed, err: 'location_check_failed' } ); } } ); } |