Permalink
Browse files

Improving error handling when PEAR_Error is configured to something o…

…ther than

its default behavior.  We rely on PEAR_ERROR_RETURN internally to detect a
number of soft error conditions, so we now request that behavior explicitly
where appropriate.

Bug: 18469
Suggested by: Peter Gyongyosi
  • Loading branch information...
1 parent 6127d2c commit aa6b60eb3716d2da3f22e97fa1849a0fbfaaca14 @jparise jparise committed Apr 26, 2011
Showing with 13 additions and 7 deletions.
  1. +12 −7 SMTP.php
  2. +1 −0 package.xml
View
@@ -263,7 +263,8 @@ function _send($data)
$result = $this->_socket->write($data);
if (!$result || PEAR::isError($result)) {
$msg = ($result) ? $result->getMessage() : "unknown error";
- return PEAR::raiseError("Failed to write to socket: $msg");
+ return PEAR::raiseError("Failed to write to socket: $msg",
+ null, PEAR_ERROR_RETURN);
}
return $result;
@@ -293,7 +294,8 @@ function _put($command, $args = '')
}
if (strcspn($command, "\r\n") !== strlen($command)) {
- return PEAR::raiseError('Commands cannot contain newlines');
+ return PEAR::raiseError('Commands cannot contain newlines',
+ null, PEAR_ERROR_RETURN);
}
return $this->_send($command . "\r\n");
@@ -332,10 +334,11 @@ function _parseResponse($valid, $later = false)
while ($line = $this->_socket->readLine()) {
$this->_debug("Recv: $line");
- /* If we receive an empty line, the connection has been closed. */
+ /* If we receive an empty line, the connection was closed. */
if (empty($line)) {
$this->disconnect();
- return PEAR::raiseError('Connection was unexpectedly closed');
+ return PEAR::raiseError('Connection was closed',
+ null, PEAR_ERROR_RETURN);
}
/* Read the code and store the rest in the arguments array. */
@@ -367,7 +370,7 @@ function _parseResponse($valid, $later = false)
}
return PEAR::raiseError('Invalid response code received from server',
- $this->_code);
+ $this->_code, PEAR_ERROR_RETURN);
}
/**
@@ -525,7 +528,8 @@ function _negotiate()
return $error;
}
if (PEAR::isError($this->_parseResponse(250))) {
- return PEAR::raiseError('HELO was not accepted: ', $this->_code);
+ return PEAR::raiseError('HELO was not accepted: ', $this->_code,
+ PEAR_ERROR_RETURN);
}
return true;
@@ -565,7 +569,8 @@ function _getBestAuthMethod()
}
}
- return PEAR::raiseError('No supported authentication methods');
+ return PEAR::raiseError('No supported authentication methods',
+ null, PEAR_ERROR_RETURN);
}
/**
View
@@ -32,6 +32,7 @@
<license uri="http://www.php.net/license/3_01.txt">PHP License</license>
<notes>- Adding a new command() method for sending arbitrary SMTP commands.
- More kinds of socket write() failures are now detected.
+- Improved PEAR_Error internal handling. (Bug 18469)
</notes>
<contents>
<dir baseinstalldir="Net" name="/">

0 comments on commit aa6b60e

Please sign in to comment.