Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'local/milestones/exceptions' into merges/prolic-excepti…
Browse files Browse the repository at this point in the history
…ons-log
  • Loading branch information
Ralph Schindler committed Oct 5, 2010
3 parents d7eb727 + ea05ef8 + ed4989b commit 964d943
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 23 deletions.
5 changes: 2 additions & 3 deletions src/Decode.php
Expand Up @@ -23,7 +23,6 @@
* @namespace
*/
namespace Zend\Mime;
use Zend;

/**
* @uses \Zend\Exception
Expand Down Expand Up @@ -72,7 +71,7 @@ public static function splitMime($body, $boundary)
// no more parts, find end boundary
$p = strpos($body, '--' . $boundary . '--', $start);
if ($p===false) {
throw new Zend\Exception('Not a valid Mime Message: End Missing');
throw new Exception\RuntimeException('Not a valid Mime Message: End Missing');
}

// the remaining part also needs to be parsed:
Expand Down Expand Up @@ -205,7 +204,7 @@ public static function splitHeaderField($field, $wantedPart = null, $firstName =

$field = $firstName . '=' . $field;
if (!preg_match_all('%([^=\s]+)\s*=\s*("[^"]+"|[^;]+)(;\s*|$)%', $field, $matches)) {
throw new Zend\Exception('not a valid header field');
throw new Exception\RuntimeException('not a valid header field');
}

if ($wantedPart) {
Expand Down
3 changes: 1 addition & 2 deletions src/Exception.php
Expand Up @@ -23,7 +23,6 @@
* @namespace
*/
namespace Zend\Mime;
use Zend;

/**
* @uses \Zend\Exception
Expand All @@ -32,6 +31,6 @@
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Exception extends Zend\Exception
interface Exception
{}

41 changes: 41 additions & 0 deletions src/Exception/RuntimeException.php
@@ -0,0 +1,41 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Mime
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @version $Id$
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

/**
* @namespace
*/
namespace Zend\Mime\Exception;
use Zend\Mime\Exception;

/**
* Exception for Zend_Mime component.
*
* @uses Zend\Exception
* @category Zend
* @package Zend_Mime
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class RuntimeException
extends \RuntimeException
implements Exception
{
}
5 changes: 2 additions & 3 deletions src/Message.php
Expand Up @@ -23,7 +23,6 @@
* @namespace
*/
namespace Zend\Mime;
use Zend;

/**
* @uses \Zend\Exception
Expand Down Expand Up @@ -221,7 +220,7 @@ protected static function _disassembleMime($body, $boundary)
// no more parts, find end boundary
$p = strpos($body, '--' . $boundary . '--', $start);
if ($p===false) {
throw new Zend\Exception('Not a valid Mime Message: End Missing');
throw new Exception\RuntimeException('Not a valid Mime Message: End Missing');
}

// the remaining part also needs to be parsed:
Expand Down Expand Up @@ -273,7 +272,7 @@ public static function createFromMessage($message, $boundary, $EOL = Mime::LINEE
$newPart->language = $value;
break;
default:
throw new Zend\Exception('Unknown header ignored for MimePart:' . $key);
throw new Exception\RuntimeException('Unknown header ignored for MimePart:' . $key);
}
}
$res->addPart($newPart);
Expand Down
6 changes: 3 additions & 3 deletions src/Part.php
Expand Up @@ -94,7 +94,7 @@ public function isStream()
public function getEncodedStream()
{
if (!$this->_isStream) {
throw new Exception('Attempt to get a stream from a string part');
throw new Exception\RuntimeException('Attempt to get a stream from a string part');
}

//stream_filter_remove(); // ??? is that right?
Expand All @@ -110,7 +110,7 @@ public function getEncodedStream()
)
);
if (!is_resource($filter)) {
throw new Exception('Failed to append quoted-printable filter');
throw new Exception\RuntimeException('Failed to append quoted-printable filter');
}
break;
case Mime::ENCODING_BASE64:
Expand All @@ -124,7 +124,7 @@ public function getEncodedStream()
)
);
if (!is_resource($filter)) {
throw new Exception('Failed to append base64 filter');
throw new Exception\RuntimeException('Failed to append base64 filter');
}
break;
default:
Expand Down
4 changes: 0 additions & 4 deletions test/MessageTest.php
Expand Up @@ -26,10 +26,6 @@
namespace ZendTest\Mime;
use Zend\Mime;

/**
* PHPUnit test case
*/

/**
* @category Zend
* @package Zend_Mime
Expand Down
8 changes: 0 additions & 8 deletions test/PartTest.php
Expand Up @@ -26,14 +26,6 @@
namespace ZendTest\Mime;
use Zend\Mime;

/**
* Zend_Mime_Part
*/

/**
* PHPUnit test case
*/

/**
* @category Zend
* @package Zend_Mime
Expand Down

0 comments on commit 964d943

Please sign in to comment.