Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401]

   1  <?php
   2  /**
   3   * Copyright 2008-2017 Horde LLC (http://www.horde.org/)
   4   *
   5   * See the enclosed file LICENSE for license information (LGPL). If you
   6   * did not receive this file, see http://www.horde.org/licenses/lgpl21.
   7   *
   8   * @category  Horde
   9   * @copyright 2008-2017 Horde LLC
  10   * @license   http://www.horde.org/licenses/lgpl21 LGPL 2.1
  11   * @package   Imap_Client
  12   */
  13  
  14  /**
  15   * Exception handler for the Horde_Imap_Client package.
  16   *
  17   * Additional server debug information MAY be found in the $details
  18   * property.
  19   *
  20   * @author    Michael Slusarz <slusarz@horde.org>
  21   * @category  Horde
  22   * @copyright 2008-2017 Horde LLC
  23   * @license   http://www.horde.org/licenses/lgpl21 LGPL 2.1
  24   * @package   Imap_Client
  25   */
  26  class Horde_Imap_Client_Exception extends Horde_Exception_Wrapped
  27  {
  28      /* Error message codes. */
  29  
  30      /**
  31       * Unspecified error (DEFAULT).
  32       */
  33      const UNSPECIFIED = 0;
  34  
  35      /**
  36       * There was an unrecoverable error in UTF7IMAP -> UTF8 conversion.
  37       */
  38      const UTF7IMAP_CONVERSION = 3;
  39  
  40      /**
  41       * The server ended the connection.
  42       */
  43      const DISCONNECT = 4;
  44  
  45      /**
  46       * The charset used in the search query is not supported on the
  47       * server. */
  48      const BADCHARSET = 5;
  49  
  50      /**
  51       * There were errors parsing the MIME/RFC 2822 header of the part.
  52       */
  53      const PARSEERROR = 6;
  54  
  55      /**
  56       * The server could not decode the MIME part (see RFC 3516).
  57       */
  58      const UNKNOWNCTE = 7;
  59  
  60      /**
  61       * The comparator specified by setComparator() was not recognized by the
  62       * IMAP server
  63       */
  64      const BADCOMPARATOR = 9;
  65  
  66      /**
  67       * RFC 7162 [3.1.2.2] - All mailboxes are not required to support
  68       * mod-sequences.
  69       */
  70      const MBOXNOMODSEQ = 10;
  71  
  72      /**
  73       * Thrown if server denies the network connection.
  74       */
  75      const SERVER_CONNECT = 11;
  76  
  77      /**
  78       * Thrown if read error for server response.
  79       */
  80      const SERVER_READERROR = 12;
  81  
  82      /**
  83       * Thrown if write error in server interaction.
  84       */
  85      const SERVER_WRITEERROR = 16;
  86  
  87      /**
  88       * Thrown on CATENATE if the URL is invalid.
  89       */
  90      const CATENATE_BADURL = 13;
  91  
  92      /**
  93       * Thrown on CATENATE if the message was too big.
  94       */
  95      const CATENATE_TOOBIG = 14;
  96  
  97      /**
  98       * Thrown on CREATE if special-use attribute is not supported.
  99       */
 100      const USEATTR = 15;
 101  
 102      /**
 103       * The user did not have permissions to carry out the operation.
 104       */
 105      const NOPERM = 17;
 106  
 107      /**
 108       * The operation was not successful because another user is holding
 109       * a necessary resource. The operation may succeed if attempted later.
 110       */
 111      const INUSE = 18;
 112  
 113      /**
 114       * The operation failed because data on the server was corrupt.
 115       */
 116      const CORRUPTION = 19;
 117  
 118      /**
 119       * The operation failed because it exceeded some limit on the server.
 120       */
 121      const LIMIT = 20;
 122  
 123      /**
 124       * The operation failed because the user is over their quota.
 125       */
 126      const OVERQUOTA = 21;
 127  
 128      /**
 129       * The operation failed because the requested creation object already
 130       * exists.
 131       */
 132      const ALREADYEXISTS = 22;
 133  
 134      /**
 135       * The operation failed because the requested deletion object did not
 136       * exist.
 137       */
 138      const NONEXISTENT = 23;
 139  
 140      /**
 141       * Setting metadata failed because the size of its value is too large.
 142       * The maximum octet count the server is willing to accept will be
 143       * in the exception message string.
 144       */
 145      const METADATA_MAXSIZE = 24;
 146  
 147      /**
 148       * Setting metadata failed because the maximum number of allowed
 149       * annotations has already been reached.
 150       */
 151      const METADATA_TOOMANY = 25;
 152  
 153      /**
 154       * Setting metadata failed because the server does not support private
 155       * annotations on one of the specified mailboxes.
 156       */
 157      const METADATA_NOPRIVATE = 26;
 158  
 159      /**
 160       * Invalid metadata entry.
 161       */
 162      const METADATA_INVALID = 27;
 163  
 164  
 165      // Login failures
 166  
 167      /**
 168       * Could not start mandatory TLS connection.
 169       */
 170      const LOGIN_TLSFAILURE = 100;
 171  
 172      /**
 173       * Could not find an available authentication method.
 174       */
 175      const LOGIN_NOAUTHMETHOD = 101;
 176  
 177      /**
 178       * Generic authentication failure.
 179       */
 180      const LOGIN_AUTHENTICATIONFAILED = 102;
 181  
 182      /**
 183       * Remote server is unavailable.
 184       */
 185      const LOGIN_UNAVAILABLE = 103;
 186  
 187      /**
 188       * Authentication succeeded, but authorization failed.
 189       */
 190      const LOGIN_AUTHORIZATIONFAILED = 104;
 191  
 192      /**
 193       * Authentication is no longer permitted with this passphrase.
 194       */
 195      const LOGIN_EXPIRED = 105;
 196  
 197      /**
 198       * Login requires privacy.
 199       */
 200      const LOGIN_PRIVACYREQUIRED = 106;
 201  
 202      /**
 203       * Server verification failed (SCRAM authentication).
 204       */
 205      const LOGIN_SERVER_VERIFICATION_FAILED = 107;
 206  
 207  
 208      // Mailbox access failures
 209  
 210      /**
 211       * Could not open/access mailbox
 212       */
 213      const MAILBOX_NOOPEN = 200;
 214  
 215      /**
 216       * Could not complete the command because the mailbox is read-only
 217       */
 218      const MAILBOX_READONLY = 201;
 219  
 220  
 221      // POP3 specific error codes
 222  
 223      /**
 224       * Temporary issue. Generally, there is no need to alarm the user for
 225       * errors of this type.
 226       */
 227      const POP3_TEMP_ERROR = 300;
 228  
 229      /**
 230       * Permanent error indicated by server.
 231       */
 232      const POP3_PERM_ERROR = 301;
 233  
 234  
 235      // Unsupported feature error codes
 236  
 237      /**
 238       * Function/feature is not supported on this server.
 239       */
 240      const NOT_SUPPORTED = 400;
 241  
 242  
 243      /**
 244       * Raw error message (in English).
 245       *
 246       * @since 2.18.0
 247       *
 248       * @var string
 249       */
 250      public $raw_msg = '';
 251  
 252      /**
 253       * Constructor.
 254       *
 255       * @param string $message  Error message (non-translated).
 256       * @param int $code        Error code.
 257       */
 258      public function __construct($message = null, $code = null)
 259      {
 260          parent::__construct($message, $code);
 261  
 262          $this->raw_msg = $this->message;
 263          try {
 264              $this->message = Horde_Imap_Client_Translation::t($this->message);
 265          } catch (Horde_Translation_Exception $e) {}
 266      }
 267  
 268      /**
 269       * Allow the error message to be altered.
 270       *
 271       * @param string $msg  Error message.
 272       */
 273      public function setMessage($msg)
 274      {
 275          $this->message = strval($msg);
 276      }
 277  
 278      /**
 279       * Allow the error code to be altered.
 280       *
 281       * @param integer $code  Error code.
 282       */
 283      public function setCode($code)
 284      {
 285          $this->code = intval($code);
 286      }
 287  
 288      /**
 289       * Perform substitution of variables in the error message.
 290       *
 291       * Needed to allow for correct translation of error message.
 292       *
 293       * @since 2.22.0
 294       *
 295       * @param array $args  Arguments used for substitution.
 296       */
 297      public function messagePrintf(array $args = array())
 298      {
 299          $this->raw_msg = vsprintf($this->raw_msg, $args);
 300          $this->message = vsprintf($this->message, $args);
 301      }
 302  
 303  }