From 72650d4cc41c64136d064967d7fec3726d850fee Mon Sep 17 00:00:00 2001
From: Ludovic Poitou <ludovic.poitou@forgerock.com>
Date: Thu, 14 Oct 2010 11:52:28 +0000
Subject: [PATCH] Multiple enhancements and bug fixes to the SDK (update from OpenDS by matthew_swift):
---
sdk/src/org/opends/sdk/ErrorResultException.java | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 55 insertions(+), 0 deletions(-)
diff --git a/sdk/src/org/opends/sdk/ErrorResultException.java b/sdk/src/org/opends/sdk/ErrorResultException.java
index f64756f..6d57f82 100644
--- a/sdk/src/org/opends/sdk/ErrorResultException.java
+++ b/sdk/src/org/opends/sdk/ErrorResultException.java
@@ -31,6 +31,7 @@
import java.util.concurrent.ExecutionException;
+import org.opends.sdk.responses.Responses;
import org.opends.sdk.responses.Result;
@@ -42,6 +43,60 @@
@SuppressWarnings("serial")
public class ErrorResultException extends ExecutionException
{
+
+ /**
+ * Creates a new error result exception with the provided result code and
+ * diagnostic message.
+ *
+ * @param resultCode
+ * The result code.
+ * @param diagnosticMessage
+ * The diagnostic message, which may be empty or {@code null}
+ * indicating that none was provided.
+ * @return The new error result exception.
+ * @throws IllegalArgumentException
+ * If the provided result code does not represent a failure.
+ * @throws NullPointerException
+ * If {@code resultCode} was {@code null}.
+ */
+ public static ErrorResultException newErrorResult(ResultCode resultCode,
+ String diagnosticMessage) throws IllegalArgumentException,
+ NullPointerException
+ {
+ return newErrorResult(resultCode, diagnosticMessage, null);
+ }
+
+
+
+ /**
+ * Creates a new error result exception with the provided result code,
+ * diagnostic message, and cause.
+ *
+ * @param resultCode
+ * The result code.
+ * @param diagnosticMessage
+ * The diagnostic message, which may be empty or {@code null}
+ * indicating that none was provided.
+ * @param cause
+ * The throwable cause, which may be null indicating that none was
+ * provided.
+ * @return The new error result exception.
+ * @throws IllegalArgumentException
+ * If the provided result code does not represent a failure.
+ * @throws NullPointerException
+ * If {@code resultCode} was {@code null}.
+ */
+ public static ErrorResultException newErrorResult(ResultCode resultCode,
+ String diagnosticMessage, Throwable cause)
+ throws IllegalArgumentException, NullPointerException
+ {
+ Result result = Responses.newResult(resultCode)
+ .setDiagnosticMessage(diagnosticMessage).setCause(cause);
+ return wrap(result);
+ }
+
+
+
/**
* Wraps the provided result in an appropriate error result exception. The
* type of error result exception used depends on the underlying result code.
--
Gitblit v1.10.0