Skip to content

Commit

Permalink
using cake_error for error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
AD7six committed Mar 19, 2011
1 parent 268c061 commit 1f6346c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lib/Cake/Network/CakeRequest.php
Expand Up @@ -380,7 +380,7 @@ public function __call($name, $params) {
$type = strtolower(substr($name, 2));
return $this->is($type);
}
throw new CakeException(__d('cake', 'Method %s does not exist', $name));
throw new CakeException(__d('cake_error', 'Method %s does not exist', $name));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Network/CakeResponse.php
Expand Up @@ -459,7 +459,7 @@ public function statusCode($code = null) {
return $this->_status;
}
if (!isset($this->_statusCodes[$code])) {
throw new CakeException(__d('cake', 'Unknown status code'));
throw new CakeException(__d('cake_error', 'Unknown status code'));
}
return $this->_status = $code;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Network/CakeSocket.php
Expand Up @@ -221,7 +221,7 @@ public function read($length = 1024) {
$buffer = fread($this->connection, $length);
$info = stream_get_meta_data($this->connection);
if ($info['timed_out']) {
$this->setLastError(E_WARNING, __d('cake', 'Connection timed out'));
$this->setLastError(E_WARNING, __d('cake_error', 'Connection timed out'));
return false;
}
return $buffer;
Expand Down
6 changes: 3 additions & 3 deletions lib/Cake/Network/Http/HttpResponse.php
Expand Up @@ -126,11 +126,11 @@ public function isOk() {
*/
public function parseResponse($message) {
if (!is_string($message)) {
throw new SocketException(__d('cake', 'Invalid response.'));
throw new SocketException(__d('cake_error', 'Invalid response.'));
}

if (!preg_match("/^(.+\r\n)(.*)(?<=\r\n)\r\n/Us", $message, $match)) {
throw new SocketException(__d('cake', 'Invalid HTTP response.'));
throw new SocketException(__d('cake_error', 'Invalid HTTP response.'));
}

list(, $statusLine, $header) = $match;
Expand Down Expand Up @@ -198,7 +198,7 @@ protected function _decodeChunkedBody($body) {

while ($chunkLength !== 0) {
if (!preg_match("/^([0-9a-f]+) *(?:;(.+)=(.+))?\r\n/iU", $body, $match)) {
throw new SocketException(__d('cake', 'HttpSocket::_decodeChunkedBody - Could not parse malformed chunk.'));
throw new SocketException(__d('cake_error', 'HttpSocket::_decodeChunkedBody - Could not parse malformed chunk.'));
}

$chunkSize = 0;
Expand Down
16 changes: 8 additions & 8 deletions lib/Cake/Network/Http/HttpSocket.php
Expand Up @@ -211,7 +211,7 @@ public function setContentResource($resource) {
return;
}
if (!is_resource($resource)) {
throw new SocketException(__d('cake', 'Invalid resource.'));
throw new SocketException(__d('cake_error', 'Invalid resource.'));
}
$this->_contentResource = $resource;
}
Expand Down Expand Up @@ -364,7 +364,7 @@ public function request($request = array()) {
}

if (!App::import('Lib', $this->responseClass)) {
throw new SocketException(__d('cake', 'Class %s not found.', $this->responseClass));
throw new SocketException(__d('cake_error', 'Class %s not found.', $this->responseClass));
}
$responseClass = $this->responseClass;
$this->response = new $responseClass($response);
Expand Down Expand Up @@ -535,10 +535,10 @@ protected function _setAuth() {
App::uses($authClass, $plugin . 'Network/Http');

if (!class_exists($authClass)) {
throw new SocketException(__d('cake', 'Unknown authentication method.'));
throw new SocketException(__d('cake_error', 'Unknown authentication method.'));
}
if (!method_exists($authClass, 'authentication')) {
throw new SocketException(sprintf(__d('cake', 'The %s do not support authentication.'), $authClass));
throw new SocketException(sprintf(__d('cake_error', 'The %s do not support authentication.'), $authClass));
}
call_user_func_array("$authClass::authentication", array($this, &$this->_auth[$method]));
}
Expand All @@ -564,10 +564,10 @@ protected function _setProxy() {
App::uses($authClass, $plugin. 'Network/Http');

if (!class_exists($authClass)) {
throw new SocketException(__d('cake', 'Unknown authentication method for proxy.'));
throw new SocketException(__d('cake_error', 'Unknown authentication method for proxy.'));
}
if (!method_exists($authClass, 'proxyAuthentication')) {
throw new SocketException(sprintf(__d('cake', 'The %s do not support proxy authentication.'), $authClass));
throw new SocketException(sprintf(__d('cake_error', 'The %s do not support proxy authentication.'), $authClass));
}
call_user_func_array("$authClass::proxyAuthentication", array($this, &$this->_proxy));
}
Expand Down Expand Up @@ -785,7 +785,7 @@ protected function _buildRequestLine($request = array(), $versionToken = 'HTTP/1
if (is_string($request)) {
$isValid = preg_match("/(.+) (.+) (.+)\r\n/U", $request, $match);
if (!$this->quirksMode && (!$isValid || ($match[2] == '*' && !in_array($match[3], $asteriskMethods)))) {
throw new SocketException(__d('cake', 'HttpSocket::_buildRequestLine - Passed an invalid request line string. Activate quirks mode to do this.'));
throw new SocketException(__d('cake_error', 'HttpSocket::_buildRequestLine - Passed an invalid request line string. Activate quirks mode to do this.'));
}
return $request;
} elseif (!is_array($request)) {
Expand All @@ -803,7 +803,7 @@ protected function _buildRequestLine($request = array(), $versionToken = 'HTTP/1
}

if (!$this->quirksMode && $request['uri'] === '*' && !in_array($request['method'], $asteriskMethods)) {
throw new SocketException(__d('cake', 'HttpSocket::_buildRequestLine - The "*" asterisk character is only allowed for the following methods: %s. Activate quirks mode to work outside of HTTP/1.1 specs.', implode(',', $asteriskMethods)));
throw new SocketException(__d('cake_error', 'HttpSocket::_buildRequestLine - The "*" asterisk character is only allowed for the following methods: %s. Activate quirks mode to work outside of HTTP/1.1 specs.', implode(',', $asteriskMethods)));
}
return $request['method'] . ' ' . $request['uri'] . ' ' . $versionToken . "\r\n";
}
Expand Down

0 comments on commit 1f6346c

Please sign in to comment.