diff options
author | uckelman <uckelman@nomic.net> | 2010-04-11 18:52:32 +0000 |
---|---|---|
committer | uckelman <uckelman@nomic.net> | 2010-04-11 18:52:32 +0000 |
commit | a9880643f1adebb81112835d665fb8b5b6904491 (patch) | |
tree | 081d266ceed7e1bca1e773f271a627c38505de5c /src/M2F.php | |
parent | 1f0296634b0387358421f50c8ea45fc45a22f312 (diff) |
Print exception stack traces.
git-svn-id: https://vassalengine.svn.sourceforge.net/svnroot/vassalengine/site-src/trunk@6668 67b53d14-2c14-4ace-a08f-0dab2b34000c
Diffstat (limited to 'src/M2F.php')
-rw-r--r-- | src/M2F.php | 99 |
1 files changed, 52 insertions, 47 deletions
diff --git a/src/M2F.php b/src/M2F.php index 8318461..d28c450 100644 --- a/src/M2F.php +++ b/src/M2F.php @@ -1,53 +1,58 @@ <?php -require_once(__DIR__ . '/Bridge.php'); -require_once(__DIR__ . '/MailmanLib.php'); -require_once(__DIR__ . '/MailmanMessage.php'); -require_once(__DIR__ . '/PhpBB3.php'); - -# Read the message from STDIN -$url = 'php://stdin'; - -$input = read_raw_message($url); -$msg = new MailmanMessage($input); - -$bridge = new Bridge(); - -$messageId = $msg->getMessageId(); -$inReplyTo = $msg->getInReplyTo(); -$rererences = $msg->getReferences(); - -$seen = !$bridge->registerMessage($messageId, $inReplyTo, $references); - -if ($seen) { - # This message has already been processed. - print 'Message id already seen, skipping: ' . $messageId . "\n"; - exit; +try { + require_once(__DIR__ . '/Bridge.php'); + require_once(__DIR__ . '/MailmanLib.php'); + require_once(__DIR__ . '/MailmanMessage.php'); + require_once(__DIR__ . '/PhpBB3.php'); + + # Read the message from STDIN + $url = 'php://stdin'; + + $input = read_raw_message($url); + $msg = new MailmanMessage($input); + + $bridge = new Bridge(); + + $messageId = $msg->getMessageId(); + $inReplyTo = $msg->getInReplyTo(); + $rererences = $msg->getReferences(); + + $seen = !$bridge->registerMessage($messageId, $inReplyTo, $references); + + if ($seen) { + # This message has already been processed. + print 'Message id already seen, skipping: ' . $messageId . "\n"; + exit; + } + + $phpbb = new PhpBB3(); + + $forumId = $topicId = -1; + $postType = null; + + if ($inReplyTo) { + # A reply to an existing topic + # FIXME: we don't want exceptions here? + $parentId = $bridge->getPostId($inReplyTo); + $ids = $phpbb->getTopicAndForumIds($parentId); + $forumId = $ids['forum_id']; + $topicId = $ids['topic_id']; + $postType = 'reply'; + } + else { + # A message starting a new topic + $forumId = $bridge->getDefaultForumId($msg->getSource()); + $postType = 'post'; + } + + # Post the message to the forum + $phpbb->postMessage($postType, $forumId, $topicId, $msg); + + $bridge->setPostId($messageId, $postId); } - -$phpbb = new PhpBB3(); - -$forumId = $topicId = -1; -$postType = null; - -if ($inReplyTo) { - # A reply to an existing topic -# FIXME: we don't want exceptions here? - $parentId = $bridge->getPostId($inReplyTo); - $ids = $phpbb->getTopicAndForumIds($parentId); - $forumId = $ids['forum_id']; - $topicId = $ids['topic_id']; - $postType = 'reply'; +catch (Exception $e) { + print $e->getTraceAsString(); } -else { - # A message starting a new topic - $forumId = $bridge->getDefaultForumId($msg->getSource()); - $postType = 'post'; -} - -# Post the message to the forum -$phpbb->postMessage($postType, $forumId, $topicId, $msg); - -$bridge->setPostId($messageId, $postId); ?> |