Skip to content

Commit

Permalink
Emit errors send Exception objects
Browse files Browse the repository at this point in the history
  • Loading branch information
cboden committed May 10, 2012
1 parent be42ab5 commit 3007eb7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/React/Http/RequestHeaderParser.php
Expand Up @@ -14,7 +14,7 @@ class RequestHeaderParser extends EventEmitter
public function feed($data)
{
if (strlen($this->buffer) + strlen($data) > $this->maxSize) {
$this->emit('error', array("Maximum header size of {$this->maxSize} exceeded."));
$this->emit('error', array(new \OverflowException("Maximum header size of {$this->maxSize} exceeded."), $this));
return;
}

Expand Down
4 changes: 2 additions & 2 deletions src/React/Socket/Buffer.php
Expand Up @@ -63,13 +63,13 @@ public function handleWrite()
$sent = fwrite($this->socket, $this->data);
} catch (\ErrorException $e) {
$sent = false;
$error = $e->getMessage();
$error = $e;
}

restore_error_handler();

if (false === $sent) {
$error = $error ?: 'Unable to write to socket';
$error = $error ?: new \RuntimeException('Unable to write to socket');
$this->emit('error', array($error));
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/React/Socket/Server.php
Expand Up @@ -28,7 +28,7 @@ public function listen($port, $host = '127.0.0.1')
$this->loop->addReadStream($this->master, function ($master) use ($that) {
$newSocket = stream_socket_accept($master);
if (false === $newSocket) {
$that->emit('error', array('Error accepting new connection'));
$that->emit('error', array(new \RuntimeException('Error accepting new connection')));
return;
}
$that->handleConnection($newSocket);
Expand Down

0 comments on commit 3007eb7

Please sign in to comment.