From 2ed3a952a6756c0cc50dbe157b5454ec2ae8385a Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 8 Apr 2011 16:50:56 +0200 Subject: [PATCH] Add error response. --- .../pterodactylus/sone/freenet/fcp/Command.java | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/main/java/net/pterodactylus/sone/freenet/fcp/Command.java b/src/main/java/net/pterodactylus/sone/freenet/fcp/Command.java index faa10db..2a083ee 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/fcp/Command.java +++ b/src/main/java/net/pterodactylus/sone/freenet/fcp/Command.java @@ -17,6 +17,7 @@ package net.pterodactylus.sone.freenet.fcp; +import net.pterodactylus.sone.freenet.SimpleFieldSetBuilder; import freenet.support.SimpleFieldSet; import freenet.support.api.Bucket; @@ -178,4 +179,36 @@ public interface Command { } + /** + * Response implementation that can return an error message and an optional + * error code. + * + * @author David ‘Bombe’ Roden + */ + public class ErrorResponse extends Response { + + /** + * Creates a new error response with the given message. + * + * @param message + * The error message + */ + public ErrorResponse(String message) { + super(new SimpleFieldSetBuilder().put("ErrorMessage", message).get()); + } + + /** + * Creates a new error response with the given code and message. + * + * @param code + * The error code + * @param message + * The error message + */ + public ErrorResponse(int code, String message) { + super(new SimpleFieldSetBuilder().put("ErrorMessage", message).put("ErrorCode", code).get()); + } + + } + } -- 2.7.4