From 15a8239afef0bf46bc7b1221a8c68a59568055d2 Mon Sep 17 00:00:00 2001 From: Colin McDonald Date: Sun, 6 Mar 2016 00:02:30 -0500 Subject: [PATCH] Change error method signatures to reduce code verbosity --- .../java/net/frozenorb/apiv3/util/ErrorUtils.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/frozenorb/apiv3/util/ErrorUtils.java b/src/main/java/net/frozenorb/apiv3/util/ErrorUtils.java index 8d3ccf7..7cd0ae5 100644 --- a/src/main/java/net/frozenorb/apiv3/util/ErrorUtils.java +++ b/src/main/java/net/frozenorb/apiv3/util/ErrorUtils.java @@ -8,21 +8,21 @@ import java.util.UUID; @UtilityClass public class ErrorUtils { - public static Document createResponse(Throwable throwable) { + public static String toResponseString(Throwable throwable) { // We do this identifier thing so we can easily search logs for the exception. // We can't send the stack trace to the user, so this is a good alternative. String identifier = UUID.randomUUID().toString(); System.out.println("[Caught exception] Identifier=" + identifier); throwable.printStackTrace(); - return createResponse(throwable.getClass().getSimpleName(), identifier); + return toResponseString(throwable.getClass().getSimpleName(), identifier); } - public static Document createResponse(String reason) { - return createResponse(reason, null); + public static String toResponseString(String reason) { + return toResponseString(reason, null); } - private static Document createResponse(String reason, String identifier) { + private static String toResponseString(String reason, String identifier) { Document json = new Document(); json.put("failed", true); @@ -32,7 +32,7 @@ public class ErrorUtils { json.put("identifier", identifier); } - return json; + return json.toJson(); } } \ No newline at end of file