Skip to content

Commit

Permalink
[mms] Add raw error message text (in English) to Exceptions.
Browse files Browse the repository at this point in the history
  • Loading branch information
slusarz committed Jan 28, 2014
1 parent 1d082a0 commit f9356c4
Show file tree
Hide file tree
Showing 14 changed files with 152 additions and 81 deletions.
8 changes: 8 additions & 0 deletions framework/Imap_Client/doc/Horde/Imap/Client/UPGRADING
Expand Up @@ -11,6 +11,14 @@
This lists the API changes between releases of the package.


Upgrading to 2.18.0
===================

- Horde_Imap_Client_Exception

Added the $raw_msg parameter.


Upgrading to 2.17.0
===================

Expand Down
Expand Up @@ -154,7 +154,10 @@ protected function _parseChallenge($challenge)

// Required directives.
if (!isset($tokens['nonce']) || !isset($tokens['algorithm'])) {
throw new Horde_Imap_Client_Exception(Horde_Imap_Client_Translation::t("Authentication failure."), 'SERVER_CONNECT');
throw new Horde_Imap_Client_Exception(
Horde_Imap_Client_Translation::gettext_define("Authentication failure."),
'SERVER_CONNECT'
);
}

return $tokens;
Expand Down
12 changes: 6 additions & 6 deletions framework/Imap_Client/lib/Horde/Imap/Client/Base.php
Expand Up @@ -2029,7 +2029,7 @@ public function close(array $options = array())
$this->openMailbox($this->_selected, Horde_Imap_Client::OPEN_READWRITE);
if ($this->_mode == Horde_Imap_Client::OPEN_READONLY) {
throw new Horde_Imap_Client_Exception(
Horde_Imap_Client_Translation::t("Cannot expunge read-only mailbox."),
Horde_Imap_Client_Translation::gettext_define("Cannot expunge read-only mailbox."),
Horde_Imap_Client_Exception::MAILBOX_READONLY
);
}
Expand Down Expand Up @@ -2092,7 +2092,7 @@ public function expunge($mailbox, array $options = array())
/* Don't expunge if the mailbox is readonly. */
if ($this->_mode == Horde_Imap_Client::OPEN_READONLY) {
throw new Horde_Imap_Client_Exception(
Horde_Imap_Client_Translation::t("Cannot expunge read-only mailbox."),
Horde_Imap_Client_Translation::gettext_define("Cannot expunge read-only mailbox."),
Horde_Imap_Client_Exception::MAILBOX_READONLY
);
}
Expand Down Expand Up @@ -2362,7 +2362,7 @@ public function search($mailbox, $query = null, array $options = array())
if (in_array('CONDSTORE', $options['_query']['exts']) &&
!$this->_mailboxOb()->getStatus(Horde_Imap_Client::STATUS_HIGHESTMODSEQ)) {
throw new Horde_Imap_Client_Exception(
Horde_Imap_Client_Translation::t("Mailbox does not support mod-sequences."),
Horde_Imap_Client_Translation::gettext_define("Mailbox does not support mod-sequences."),
Horde_Imap_Client_Exception::MBOXNOMODSEQ
);
}
Expand Down Expand Up @@ -2682,7 +2682,7 @@ private function _fetchWrapper($mailbox, $query, $options)
/* RFC 4551 [3.1] - trying to do a MODSEQ FETCH on a mailbox that
* doesn't support it will return BAD. */
throw new Horde_Imap_Client_Exception(
Horde_Imap_Client_Translation::t("Mailbox does not support mod-sequences."),
Horde_Imap_Client_Translation::gettext_define("Mailbox does not support mod-sequences."),
Horde_Imap_Client_Exception::MBOXNOMODSEQ
);
}
Expand Down Expand Up @@ -2947,7 +2947,7 @@ public function vanished($mailbox, $modseq, array $opts = array())
if ($qresync) {
if (!$this->_mailboxOb()->getStatus(Horde_Imap_Client::STATUS_HIGHESTMODSEQ)) {
throw new Horde_Imap_Client_Exception(
Horde_Imap_Client_Translation::t("Mailbox does not support mod-sequences."),
Horde_Imap_Client_Translation::gettext_define("Mailbox does not support mod-sequences."),
Horde_Imap_Client_Exception::MBOXNOMODSEQ
);
}
Expand Down Expand Up @@ -3032,7 +3032,7 @@ public function store($mailbox, array $options = array())
* mailbox that doesn't support it will return BAD. */
if (!$this->_mailboxOb()->getStatus(Horde_Imap_Client::STATUS_HIGHESTMODSEQ)) {
throw new Horde_Imap_Client_Exception(
Horde_Imap_Client_Translation::t("Mailbox does not support mod-sequences."),
Horde_Imap_Client_Translation::gettext_define("Mailbox does not support mod-sequences."),
Horde_Imap_Client_Exception::MBOXNOMODSEQ
);
}
Expand Down
27 changes: 26 additions & 1 deletion framework/Imap_Client/lib/Horde/Imap/Client/Exception.php
Expand Up @@ -23,7 +23,7 @@
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Imap_Client
*/
class Horde_Imap_Client_Exception extends Horde_Exception_Wrapped
class Horde_Imap_Client_Exception extends Horde_Exception
{
/* Error message codes. */

Expand Down Expand Up @@ -161,6 +161,31 @@ class Horde_Imap_Client_Exception extends Horde_Exception_Wrapped
const NOT_SUPPORTED = 400;


/**
* Raw error message (in English).
*
* @since 2.18.0
*
* @var string
*/
public $raw_msg = '';

/**
* Constructor.
*
* @param string $msg Error message (non-translated).
* @param code $code Error code.
*/
public function __construct($message = null, $code = null)
{
parent::__construct(
Horde_Imap_Client_Translation::t($message),
$code
);

$this->raw_msg = $message;
}

/**
* Allow the error message to be altered.
*
Expand Down
Expand Up @@ -20,7 +20,8 @@
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Imap_Client
*/
class Horde_Imap_Client_Exception_NoSupportExtension extends Horde_Imap_Client_Exception
class Horde_Imap_Client_Exception_NoSupportExtension
extends Horde_Imap_Client_Exception
{
/**
* The extension not supported on the server.
Expand All @@ -41,7 +42,10 @@ public function __construct($extension, $msg = null)
$this->extension = $extension;

if (is_null($msg)) {
$msg = sprintf(Horde_Imap_Client_Translation::t("The server does not support the %s extension."), $extension);
$msg = sprintf(
Horde_Imap_Client_Translation::gettext_define("The server does not support the %s extension."),
$extension
);
}

parent::__construct($msg, self::NOT_SUPPORTED);
Expand Down
Expand Up @@ -20,7 +20,8 @@
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Imap_Client
*/
class Horde_Imap_Client_Exception_NoSupportPop3 extends Horde_Imap_Client_Exception
class Horde_Imap_Client_Exception_NoSupportPop3
extends Horde_Imap_Client_Exception
{
/**
* Constructor.
Expand All @@ -30,7 +31,7 @@ class Horde_Imap_Client_Exception_NoSupportPop3 extends Horde_Imap_Client_Except
public function __construct($feature)
{
parent::__construct(
sprintf(Horde_Imap_Client_Translation::t("%s not supported on POP3 servers."), $feature),
sprintf(Horde_Imap_Client_Translation::gettext_define("%s not supported on POP3 servers."), $feature),
self::NOT_SUPPORTED
);
}
Expand Down
Expand Up @@ -21,7 +21,8 @@
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Imap_Client
*/
class Horde_Imap_Client_Exception_SearchCharset extends Horde_Imap_Client_Exception
class Horde_Imap_Client_Exception_SearchCharset
extends Horde_Imap_Client_Exception
{
/**
* Charset that was attempted to be converted to.
Expand All @@ -41,7 +42,7 @@ public function __construct($charset)
$this->charset = $charset;

parent::__construct(
Horde_Imap_Client_Translation::t("Cannot convert search query text to new charset"),
Horde_Imap_Client_Translation::gettext_define("Cannot convert search query text to new charset"),
self::BADCHARSET
);
}
Expand Down
Expand Up @@ -20,7 +20,8 @@
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Imap_Client
*/
class Horde_Imap_Client_Interaction_Server_Tagged extends Horde_Imap_Client_Interaction_Server
class Horde_Imap_Client_Interaction_Server_Tagged
extends Horde_Imap_Client_Interaction_Server
{
/**
* Tag.
Expand All @@ -39,7 +40,9 @@ public function __construct(Horde_Imap_Client_Tokenize $token, $tag)
parent::__construct($token);

if (is_null($this->status)) {
throw new Horde_Imap_Client_Exception(Horde_Imap_Client_Translation::t("Bad tagged response."));
throw new Horde_Imap_Client_Exception(
Horde_Imap_Client_Translation::gettext_define("Bad tagged response.")
);
}
}

Expand Down

0 comments on commit f9356c4

Please sign in to comment.