From 001f9be89da75fd15aec093857458a270499e681 Mon Sep 17 00:00:00 2001 From: uckelman Date: Sun, 11 Apr 2010 19:03:19 +0000 Subject: Converted trigger_error to 'throw new Exception'. git-svn-id: https://vassalengine.svn.sourceforge.net/svnroot/vassalengine/site-src/trunk@6669 67b53d14-2c14-4ace-a08f-0dab2b34000c --- src/Bridge.php | 14 ++++++-------- src/EmailMessage.php | 2 +- src/MailmanLib.php | 2 +- src/PhpBB3.php | 24 ++++++++++-------------- 4 files changed, 18 insertions(+), 24 deletions(-) diff --git a/src/Bridge.php b/src/Bridge.php index a4aa77a..05689f8 100644 --- a/src/Bridge.php +++ b/src/Bridge.php @@ -30,11 +30,11 @@ class Bridge { public function setPostId($messageId, $postId) { if ($messageId === null) { - trigger_error('message id is null', E_USER_ERROR); + throw new Exception('message id is null'); } if ($postId === null) { - trigger_error('post id is null', E_USER_ERROR); + throw new Exception('post id is null'); } $sql = 'UPDATE posts SET ' . @@ -44,9 +44,7 @@ class Bridge { $count = $this->db->exec($sql); if ($count != 1) { - trigger_error( - 'Failed to set post id: ' . $messageId, E_USER_ERROR - ); + throw new Exception('Failed to set post id: ' . $messageId); } } @@ -60,7 +58,7 @@ class Bridge { public function registerMessage($messageId, $inReplyTo, $refs) { if ($messageId === null) { - trigger_error('message id is null', E_USER_ERROR); + throw new Exception('message id is null'); } $sql = 'INSERT IGNORE INTO posts ' . @@ -82,14 +80,14 @@ class Bridge { switch (count($rows)) { case 0: - trigger_error("No rows returned: $sql", E_USER_ERROR); + throw new Exception("No rows returned: $sql"); break; case 1: return $rows[0]; default: - trigger_error("Too many rows returned: $sql", E_USER_ERROR); + throw new Exception("Too many rows returned: $sql"); break; } } diff --git a/src/EmailMessage.php b/src/EmailMessage.php index b677574..7c9ddbb 100644 --- a/src/EmailMessage.php +++ b/src/EmailMessage.php @@ -52,7 +52,7 @@ abstract class EmailMessage implements Message { if (count($msg->headers) == 1 && array_key_exists(null, $msg->headers)) { # An empty message has one null header. - trigger_error('No message', E_USER_ERROR); + throw new Exception('No message'); } return $msg; diff --git a/src/MailmanLib.php b/src/MailmanLib.php index ca3dadf..cc68d42 100644 --- a/src/MailmanLib.php +++ b/src/MailmanLib.php @@ -3,7 +3,7 @@ function read_raw_message($url) { $input = file_get_contents($url); if (!$input) { - trigger_error("No input in $url", E_USER_ERROR); + throw new Exception("No input in $url"); } return $input; } diff --git a/src/PhpBB3.php b/src/PhpBB3.php index 22234f5..37c4bdf 100644 --- a/src/PhpBB3.php +++ b/src/PhpBB3.php @@ -28,11 +28,11 @@ class PhpBB3 { $ids = array($id); $err = user_get_id_name($ids, $names); if ($err) { - trigger_error("Could not resolve user id $id: $err", E_USER_ERROR); + throw new Exception("Could not resolve user id $id: $err"); } if (!array_key_exists($id, $names)) { - trigger_error("Unknown user id: $id", E_USER_ERROR); + throw new Exception("Unknown user id: $id"); } return $names[$id]; @@ -68,8 +68,7 @@ class PhpBB3 { default: # Should be impossible due to LIMIT 1. - trigger_error("Too many rows returned: $sql", E_USER_ERROR); - break; + throw new Exception("Too many rows returned: $sql"); } } @@ -93,26 +92,25 @@ class PhpBB3 { default: # Should be impossible due to LIMIT 1. - trigger_error("Too many rows returned: $sql", E_USER_ERROR); - break; + throw new Exception("Too many rows returned: $sql"); } } public function postMessage($postType, $forumId, $topicId, $msg) { if ($postType != 'post' && $postType != 'reply') { - trigger_error('bad post type: ' . $postType, E_USER_ERROR); + throw new Exception('bad post type: ' . $postType); } if (!$this->forumExists($forumId)) { - trigger_error('forum does not exist: ' . $forumId, E_USER_ERROR); + throw new Exception('forum does not exist: ' . $forumId); } if ($postType == 'reply' && !$this->topicExists($topicId)) { - trigger_error('topic does not exist: ' . $topicId, E_USER_ERROR); + throw new Exception('topic does not exist: ' . $topicId); } if ($msg === null) { - trigger_error('message is null', E_USER_ERROR); + throw new Exception('message is null'); } $subject = $msg->getSubject(); @@ -187,15 +185,13 @@ class PhpBB3 { switch (count($rows)) { case 0: - trigger_error("No rows returned: $sql", E_USER_ERROR); - break; + throw new Exception("No rows returned: $sql"); case 1: return $rows[0]; default: - trigger_error("Too many rows returned: $sql", E_USER_ERROR); - break; + throw new Exception("Too many rows returned: $sql"); } } } -- cgit v1.2.3