aboutsummaryrefslogtreecommitdiff
path: root/src/uk/org/ury/backend/server/exceptions
diff options
context:
space:
mode:
Diffstat (limited to 'src/uk/org/ury/backend/server/exceptions')
-rw-r--r--src/uk/org/ury/backend/server/exceptions/BadRequestException.java47
-rw-r--r--src/uk/org/ury/backend/server/exceptions/HandleFailureException.java46
-rw-r--r--src/uk/org/ury/backend/server/exceptions/HandlerNotFoundException.java51
-rw-r--r--src/uk/org/ury/backend/server/exceptions/HandlerSetupFailureException.java55
-rw-r--r--src/uk/org/ury/backend/server/exceptions/HandlingException.java48
-rw-r--r--src/uk/org/ury/backend/server/exceptions/NotAHandlerException.java34
-rw-r--r--src/uk/org/ury/backend/server/exceptions/UnknownFunctionException.java37
7 files changed, 318 insertions, 0 deletions
diff --git a/src/uk/org/ury/backend/server/exceptions/BadRequestException.java b/src/uk/org/ury/backend/server/exceptions/BadRequestException.java
new file mode 100644
index 0000000..6f200f3
--- /dev/null
+++ b/src/uk/org/ury/backend/server/exceptions/BadRequestException.java
@@ -0,0 +1,47 @@
+/**
+ *
+ */
+package uk.org.ury.backend.server.exceptions;
+
+/**
+ * Exception thrown when the server meets a malformed request, or
+ * part of one.
+ *
+ * @author Matt Windsor
+ */
+
+public class BadRequestException extends HandlingException
+{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1825771401085225357L;
+
+
+ /**
+ * Construct a new BadRequestException with a default reason.
+ */
+
+ public
+ BadRequestException ()
+ {
+ super ("Bad request.");
+ }
+
+
+ /**
+ * Construct a new HandlerNotFoundException with a chained
+ * exception.
+ *
+ * @param cause The exception that this new exception is to
+ * wrap.
+ */
+
+ public
+ BadRequestException (Throwable cause)
+ {
+ super ("Bad request. ("
+ + cause.getMessage () + ")", cause);
+ }
+}
diff --git a/src/uk/org/ury/backend/server/exceptions/HandleFailureException.java b/src/uk/org/ury/backend/server/exceptions/HandleFailureException.java
new file mode 100644
index 0000000..0efb7a3
--- /dev/null
+++ b/src/uk/org/ury/backend/server/exceptions/HandleFailureException.java
@@ -0,0 +1,46 @@
+/**
+ *
+ */
+package uk.org.ury.backend.server.exceptions;
+
+/**
+ * Generic exception thrown when a server request handler fails to
+ * handle a request.
+ *
+ * @author Matt Windsor
+ */
+
+public class HandleFailureException extends HandlingException
+{
+
+ /**
+ * Change this! ---v
+ */
+
+ private static final long serialVersionUID = -397479334359858162L;
+
+
+ /**
+ * Construct a new HandleFailureException with a
+ * default reason.
+ */
+
+ public
+ HandleFailureException ()
+ {
+ super ("Server request handler failed to handle the request.");
+ }
+
+
+ /**
+ * Construct a new HandleFailureException.
+ *
+ * @param reason The explanation for the exception.
+ */
+
+ public
+ HandleFailureException (String reason)
+ {
+ super (reason);
+ }
+}
diff --git a/src/uk/org/ury/backend/server/exceptions/HandlerNotFoundException.java b/src/uk/org/ury/backend/server/exceptions/HandlerNotFoundException.java
new file mode 100644
index 0000000..a7ba136
--- /dev/null
+++ b/src/uk/org/ury/backend/server/exceptions/HandlerNotFoundException.java
@@ -0,0 +1,51 @@
+/**
+ *
+ */
+package uk.org.ury.backend.server.exceptions;
+
+/**
+ * Exception thrown when the server request handler requested
+ * by the client is not * found in the class space.
+ *
+ * @author Matt Windsor
+ */
+
+public class HandlerNotFoundException extends HandlingException
+{
+
+ /**
+ * TODO: Change this! ---v
+ */
+
+ private static final long serialVersionUID = -397479334359858162L;
+
+
+ /**
+ * Construct a new HandlerNotFoundException with a
+ * default reason.
+ */
+
+ public
+ HandlerNotFoundException ()
+ {
+ super ("Handler not found.");
+ }
+
+
+ /**
+ * Construct a new HandlerNotFoundException with a class name and
+ * chained exception.
+ *
+ * @param className The name of the missing handler class.
+ *
+ * @param cause The exception that this new exception is to
+ * wrap.
+ */
+
+ public
+ HandlerNotFoundException (String className, Throwable cause)
+ {
+ super ("Handler " + className + " not found. ("
+ + cause.getMessage () + ")", cause);
+ }
+}
diff --git a/src/uk/org/ury/backend/server/exceptions/HandlerSetupFailureException.java b/src/uk/org/ury/backend/server/exceptions/HandlerSetupFailureException.java
new file mode 100644
index 0000000..d70624a
--- /dev/null
+++ b/src/uk/org/ury/backend/server/exceptions/HandlerSetupFailureException.java
@@ -0,0 +1,55 @@
+/**
+ *
+ */
+package uk.org.ury.backend.server.exceptions;
+
+/**
+ * Exception thrown when the server request handler requested
+ * by the client cannot be set up to process the request.
+ *
+ * @author Matt Windsor
+ */
+
+public class HandlerSetupFailureException extends HandlingException
+{
+
+ /**
+ * TODO: Change this! ---v
+ */
+
+ private static final long serialVersionUID = -397479334359858162L;
+
+
+ /**
+ * Construct a new HandlerNotFoundException with a
+ * default reason.
+ */
+
+ public
+ HandlerSetupFailureException ()
+ {
+ super ("Handler setup failed.");
+ }
+
+
+ /**
+ * Construct a new HandlerSetupFailureException with a class name
+ * and chained exception.
+ *
+ * Use this to hide exception specifics from higher abstraction
+ * layers.
+ *
+ * @param className The name of the failed handler class.
+ *
+ * @param cause The exception that this new exception is to
+ * wrap.
+ */
+
+ public
+ HandlerSetupFailureException (String className,
+ Throwable cause)
+ {
+ super ("Setup for handler " + className + " failed (reason: "
+ + cause.getMessage () + ").", cause);
+ }
+}
diff --git a/src/uk/org/ury/backend/server/exceptions/HandlingException.java b/src/uk/org/ury/backend/server/exceptions/HandlingException.java
new file mode 100644
index 0000000..edca0aa
--- /dev/null
+++ b/src/uk/org/ury/backend/server/exceptions/HandlingException.java
@@ -0,0 +1,48 @@
+/**
+ *
+ */
+package uk.org.ury.backend.server.exceptions;
+
+/**
+ * Generic exception thrown when the server cannot handle a request.
+ *
+ * @author Matt Windsor
+ */
+
+public class HandlingException extends Exception
+{
+ /**
+ * TODO: Change this! ---v
+ */
+
+ private static final long serialVersionUID = -397479334359858162L;
+
+
+ /**
+ * Construct a HandlingException with a reason.
+ *
+ * @param string The reason to present.
+ */
+
+ public
+ HandlingException (String string)
+ {
+ super (string);
+ }
+
+
+ /**
+ * Construct a HandlingException with a reason and a cause to
+ * chain.
+ *
+ * @param string The reason to present.
+ *
+ * @param cause The thrown cause that this exception should wrap.
+ */
+
+ public
+ HandlingException (String string, Throwable cause)
+ {
+ super (string, cause);
+ }
+}
diff --git a/src/uk/org/ury/backend/server/exceptions/NotAHandlerException.java b/src/uk/org/ury/backend/server/exceptions/NotAHandlerException.java
new file mode 100644
index 0000000..d5c9d93
--- /dev/null
+++ b/src/uk/org/ury/backend/server/exceptions/NotAHandlerException.java
@@ -0,0 +1,34 @@
+/**
+ *
+ */
+package uk.org.ury.backend.server.exceptions;
+
+/**
+ * Exception thrown if the class requested as a handler by the client
+ * is, in fact, not a handler (it does not implement RequestHandler).
+ *
+ * @author Matt Windsor
+ */
+
+public class NotAHandlerException extends HandlingException
+{
+ /**
+ *
+ */
+ private static final long serialVersionUID = -7268289187311868036L;
+
+ /**
+ * Construct a NotAHandlerException with the name of the class that
+ * is not a handler.
+ *
+ * @param className The name of the offending class.
+ */
+
+ public
+ NotAHandlerException (String className)
+ {
+ super ("Class " + className + " is not a request handler.");
+ // TODO Auto-generated constructor stub
+ }
+
+}
diff --git a/src/uk/org/ury/backend/server/exceptions/UnknownFunctionException.java b/src/uk/org/ury/backend/server/exceptions/UnknownFunctionException.java
new file mode 100644
index 0000000..c0a8a06
--- /dev/null
+++ b/src/uk/org/ury/backend/server/exceptions/UnknownFunctionException.java
@@ -0,0 +1,37 @@
+/*
+ * UnknownFunctionException.java
+ * -----------------------------
+ *
+ * Part of the URY Server Platform
+ *
+ * V0.00 2011/03/20
+ *
+ * (C) 2011 URY Computing
+ */
+
+package uk.org.ury.backend.server.exceptions;
+
+/**
+ * Exception thrown when a handler receives a request for a path that does not
+ * correspond to one of its functions.
+ *
+ * @author Matt Windsor
+ *
+ */
+public class UnknownFunctionException extends HandlingException {
+ /**
+ *
+ */
+ private static final long serialVersionUID = -7557785978712465975L;
+
+ /**
+ * Construct a new UnknownFunctionException.
+ *
+ * @param path
+ * The path that was requested.
+ */
+ public UnknownFunctionException(String path) {
+ super("Not found: " + path);
+ }
+
+}