From 7e4d96f16e59aacdc83c646f406dad0bead97e14 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 26 Oct 2013 14:55:11 +0200 Subject: [PATCH] Handle exception when replying only once. --- .../net/pterodactylus/sone/fcp/FcpInterface.java | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/fcp/FcpInterface.java b/src/main/java/net/pterodactylus/sone/fcp/FcpInterface.java index 0b0dcb9..2c7355d 100644 --- a/src/main/java/net/pterodactylus/sone/fcp/FcpInterface.java +++ b/src/main/java/net/pterodactylus/sone/fcp/FcpInterface.java @@ -153,24 +153,16 @@ public class FcpInterface { * {@link FredPluginFCP#ACCESS_FCP_RESTRICTED} */ public void handle(PluginReplySender pluginReplySender, SimpleFieldSet parameters, Bucket data, int accessType) { - if (!active) { - try { + try { + if (!active) { sendReply(pluginReplySender, null, new ErrorResponse(400, "FCP Interface deactivated")); - } catch (PluginNotFoundException pnfe1) { - logger.log(Level.FINE, "Could not set error to plugin.", pnfe1); + return; } - return; - } - AbstractSoneCommand command = commands.get(parameters.get("Message")); - if ((accessType == FredPluginFCP.ACCESS_FCP_RESTRICTED) && (((fullAccessRequired == FullAccessRequired.WRITING) && command.requiresWriteAccess()) || (fullAccessRequired == FullAccessRequired.ALWAYS))) { - try { + AbstractSoneCommand command = commands.get(parameters.get("Message")); + if ((accessType == FredPluginFCP.ACCESS_FCP_RESTRICTED) && (((fullAccessRequired == FullAccessRequired.WRITING) && command.requiresWriteAccess()) || (fullAccessRequired == FullAccessRequired.ALWAYS))) { sendReply(pluginReplySender, null, new ErrorResponse(401, "Not authorized")); - } catch (PluginNotFoundException pnfe1) { - logger.log(Level.FINE, "Could not set error to plugin.", pnfe1); + return; } - return; - } - try { if (command == null) { sendReply(pluginReplySender, null, new ErrorResponse("Unrecognized Message: " + parameters.get("Message"))); return; -- 2.7.4