diff --git a/src/main/java/org/dynmap/web/HttpErrorHandler.java b/src/main/java/org/dynmap/web/HttpErrorHandler.java index f2476390..189ee78f 100644 --- a/src/main/java/org/dynmap/web/HttpErrorHandler.java +++ b/src/main/java/org/dynmap/web/HttpErrorHandler.java @@ -10,6 +10,10 @@ public class HttpErrorHandler { response.getBody(); } + public static void handleForbidden(HttpResponse response) throws IOException { + handle(response, 403, "Forbidden"); + } + public static void handleNotFound(HttpResponse response) throws IOException { handle(response, 404, "Not found"); } diff --git a/src/main/java/org/dynmap/web/handlers/ClientUpdateHandler.java b/src/main/java/org/dynmap/web/handlers/ClientUpdateHandler.java index 58d33786..55607793 100644 --- a/src/main/java/org/dynmap/web/handlers/ClientUpdateHandler.java +++ b/src/main/java/org/dynmap/web/handlers/ClientUpdateHandler.java @@ -12,6 +12,7 @@ import org.bukkit.entity.Player; import org.dynmap.Client; import org.dynmap.MapManager; import org.dynmap.PlayerList; +import org.dynmap.web.HttpErrorHandler; import org.dynmap.web.HttpHandler; import org.dynmap.web.HttpRequest; import org.dynmap.web.HttpResponse; @@ -34,15 +35,19 @@ public class ClientUpdateHandler implements HttpHandler { Matcher match = updatePathPattern.matcher(path); - if (!match.matches()) + if (!match.matches()) { + HttpErrorHandler.handleForbidden(response); return; + } String worldName = match.group(1); String timeKey = match.group(2); World world = server.getWorld(worldName); - if (world == null) + if (world == null) { + HttpErrorHandler.handleNotFound(response); return; + } long current = System.currentTimeMillis(); long since = 0; diff --git a/web/map.js b/web/map.js index 6671b4fc..3595d144 100644 --- a/web/map.js +++ b/web/map.js @@ -44,6 +44,8 @@ function DynMap(options) { $.getJSON(me.options.updateUrl + 'configuration', function(configuration) { me.configure(configuration); me.initialize(); + }, function(status, statusMessage) { + alert('Could not retrieve configuration: ' + statusMessage); }); } DynMap.prototype = { @@ -333,9 +335,9 @@ DynMap.prototype = { //divs.filter(function(i){return parseInt(divs[i].attr('rel')) > timestamp+me.options.messagettl;}).remove(); }); setTimeout(function() { me.update(); }, me.options.updaterate); - }, function(request, statusText, ex) { + }, function(status, statusText, ex) { me.alertbox - .text('Could not update map') + .text('Could not update map: ' + statusText) .show(); setTimeout(function() { me.update(); }, me.options.updaterate); }