aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/exception
diff options
context:
space:
mode:
authorNathan Guse <nathaniel.guse@gmail.com>2012-07-23 19:46:21 -0500
committerUnknown Bliss <m@michaelcullum.com>2012-09-01 15:05:34 +0100
commit89f4cf6a8c10f9b0875cf7f278016aff67eb38fc (patch)
treee54d06e9d8b4b43589c2710538e14b13f529ff54 /phpBB/includes/exception
parent106c105113886f9a9e603dbb11549c06049b255f (diff)
downloadforums-89f4cf6a8c10f9b0875cf7f278016aff67eb38fc.tar
forums-89f4cf6a8c10f9b0875cf7f278016aff67eb38fc.tar.gz
forums-89f4cf6a8c10f9b0875cf7f278016aff67eb38fc.tar.bz2
forums-89f4cf6a8c10f9b0875cf7f278016aff67eb38fc.tar.xz
forums-89f4cf6a8c10f9b0875cf7f278016aff67eb38fc.zip
[ticket/10631] Use exceptions for errors. Build action list dynamically.
PHPBB3-10631
Diffstat (limited to 'phpBB/includes/exception')
-rw-r--r--phpBB/includes/exception/metadata.php69
1 files changed, 69 insertions, 0 deletions
diff --git a/phpBB/includes/exception/metadata.php b/phpBB/includes/exception/metadata.php
new file mode 100644
index 0000000000..93cc337f55
--- /dev/null
+++ b/phpBB/includes/exception/metadata.php
@@ -0,0 +1,69 @@
+<?php
+/**
+*
+* @package extension
+* @copyright (c) 2012 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+/**
+* @ignore
+*/
+if (!defined('IN_PHPBB'))
+{
+ exit;
+}
+
+/**
+ * Exception class for metadata
+ */
+class phpbb_exception_metadata extends LogicException
+{
+ const NOT_SET = 10001;
+ const INVALID = 10002;
+ const FILE_GET_CONTENTS = 10003;
+ const JSON_DECODE = 10004;
+ const FILE_DOES_NOT_EXIST = 10005;
+
+ public function __construct($code, $field_name)
+ {
+ $this->code = $code;
+ $this->field_name = $field_name;
+ }
+
+ public function __toString()
+ {
+ return sprintf($this->getErrorMessage(), $this->field_name);
+ }
+
+ public function getErrorMessage()
+ {
+ switch ($this->code)
+ {
+ case self::NOT_SET:
+ return 'The "%s" meta field has not been set.';
+ break;
+
+ case self::INVALID:
+ return 'The "%s" meta field is not valid.';
+ break;
+
+ case self::FILE_GET_CONTENTS:
+ return 'file_get_contents failed on %s';
+ break;
+
+ case self::JSON_DECODE:
+ return 'json_decode failed on %s';
+ break;
+
+ case self::FILE_DOES_NOT_EXIST:
+ return 'Required file does not exist at %s';
+ break;
+
+ default:
+ return 'An unexpected error has occurred.';
+ break;
+ }
+ }
+} \ No newline at end of file