From 84ba5e78c872681e735f8f0e6a3cd12380892e45 Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Wed, 2 Apr 2014 16:43:47 +0100 Subject: 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 --- src/js/locate.js | 14 +++++++------- 1 file 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' } ); } } ); } -- cgit v1.2.3