From 1880add7dc23ac429732bd2782b1b98ba89fa900 Mon Sep 17 00:00:00 2001 From: "Kristian S. Stangeland" Date: Sun, 13 Jan 2013 18:00:34 +0100 Subject: [PATCH] Just report HTTP errors, no need to make tickets out of them. --- .../comphenix/protocol/CommandProtocol.java | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/CommandProtocol.java b/ProtocolLib/src/main/java/com/comphenix/protocol/CommandProtocol.java index c722eb53..672c4127 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/CommandProtocol.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/CommandProtocol.java @@ -17,6 +17,8 @@ package com.comphenix.protocol; +import java.io.IOException; + import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.bukkit.plugin.Plugin; @@ -74,7 +76,11 @@ class CommandProtocol extends CommandBase { UpdateResult result = updater.update(UpdateType.NO_DOWNLOAD, true); sender.sendMessage(ChatColor.BLUE + "[ProtocolLib] " + result.toString()); } catch (Exception e) { - getReporter().reportDetailed(this, "Cannot check updates for ProtocolLib.", e, sender); + if (isHttpError(e)) { + getReporter().reportWarning(this, "Http error: " + e.getCause().getMessage()); + } else { + getReporter().reportDetailed(this, "Cannot check updates for ProtocolLib.", e, sender); + } } } }, 0L); @@ -91,7 +97,11 @@ class CommandProtocol extends CommandBase { UpdateResult result = updater.update(UpdateType.DEFAULT, true); sender.sendMessage(ChatColor.BLUE + "[ProtocolLib] " + result.toString()); } catch (Exception e) { - getReporter().reportDetailed(this, "Cannot update ProtocolLib.", e, sender); + if (isHttpError(e)) { + getReporter().reportWarning(this, "Http error: " + e.getCause().getMessage()); + } else { + getReporter().reportDetailed(this, "Cannot update ProtocolLib.", e, sender); + } } } }, 0L); @@ -99,6 +109,17 @@ class CommandProtocol extends CommandBase { updateFinished(); } + private boolean isHttpError(Exception e) { + Throwable cause = e.getCause(); + + if (cause instanceof IOException) { + // Thanks for making the message a part of the API ... + return cause.getMessage().contains("HTTP response"); + } else { + return false; + } + } + /** * Prevent further automatic updates until the next delay. */