From dfc7a02e00e7e41e16459fe01a4787d63cb304a2 Mon Sep 17 00:00:00 2001 From: Keith Irwin Date: Mon, 7 Aug 2017 18:23:08 -0400 Subject: [PATCH] Better error handling --- script.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/script.js b/script.js index 1027b3c..2946baf 100644 --- a/script.js +++ b/script.js @@ -107,8 +107,19 @@ if (!navigator.geolocation){ // Got error function(err) { - alert("No geolocation position available!"); - console.error(err); + console.error(err.message); + if (err.code==1) { + alert("You can't use this app without granting permission to access your location"); + } + else if (err.code==2) { + alert("Location data not available."); + } + else if (err.code==3) { + alert("Timed out trying to determine location."); + } + else { + alert("An unknown error occured while trying to determine location."); + } }, // Options