setCode() public méthode

Allow the error code to be altered.
public setCode ( integer $code )
$code integer Error code.
Exemple #1
0
 /**
  * Connects to the IMAP server.
  *
  * @throws Horde_Imap_Client_Exception
  */
 protected function _connect()
 {
     if (!is_null($this->_stream)) {
         return;
     }
     if (!empty($this->_params['secure']) && !extension_loaded('openssl')) {
         throw new InvalidArgumentException('Secure connections require the PHP openssl extension.');
     }
     switch ($this->_params['secure']) {
         case 'ssl':
         case 'sslv2':
         case 'sslv3':
             $conn = $this->_params['secure'] . '://';
             $this->_isSecure = true;
             break;
         case 'tls':
         default:
             $conn = 'tcp://';
             break;
     }
     $this->_stream = @stream_socket_client($conn . $this->_params['hostspec'] . ':' . $this->_params['port'], $error_number, $error_string, $this->_params['timeout']);
     if ($this->_stream === false) {
         $this->_stream = null;
         $this->_isSecure = false;
         $e = new Horde_Imap_Client_Exception(Horde_Imap_Client_Translation::t("Error connecting to mail server."), Horde_Imap_Client_Exception::SERVER_CONNECT);
         $e->details = sprintf("[%u] %s", $error_number, $error_string);
         throw $e;
     }
     stream_set_timeout($this->_stream, $this->_params['timeout']);
     // If we already have capability information, don't re-set with
     // (possibly) limited information sent in the inital banner.
     if (isset($this->_init['capability'])) {
         $this->_temp['no_cap'] = true;
     }
     /* Get greeting information.  This is untagged so we need to specially
      * deal with it here. */
     try {
         $this->_getLine();
     } catch (Horde_Imap_Client_Exception_ServerResponse $e) {
         if ($e->status == Horde_Imap_Client_Interaction_Server::BYE) {
             /* Server is explicitly rejecting our connection (RFC 3501
              * [7.1.5]). */
             $e->setMessage(Horde_Imap_Client_Translation::t("Server rejected connection."));
             $e->setCode(Horde_Imap_Client_Exception::SERVER_CONNECT);
         }
         throw $e;
     }
     // Check for IMAP4rev1 support
     if (!$this->queryCapability('IMAP4REV1')) {
         throw new Horde_Imap_Client_Exception(Horde_Imap_Client_Translation::t("The mail server does not support IMAP4rev1 (RFC 3501)."), Horde_Imap_Client_Exception::SERVER_CONNECT);
     }
     // Set language if NOT using imapproxy
     if (empty($this->_init['imapproxy'])) {
         if ($this->queryCapability('XIMAPPROXY')) {
             $this->_setInit('imapproxy', true);
         } else {
             $this->setLanguage();
         }
     }
     // If pre-authenticated, we need to do all login tasks now.
     if (!empty($this->_temp['preauth'])) {
         $this->login();
     }
 }