From: David ‘Bombe’ Roden Date: Fri, 8 Apr 2011 14:50:56 +0000 (+0200) Subject: Add error response. X-Git-Tag: 0.6.5^2~39^2~31 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=2ed3a952a6756c0cc50dbe157b5454ec2ae8385a;p=Sone.git Add error response. --- 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()); + } + + } + }