Permalink
Browse files

Added changelog and readme section on error handling

  • Loading branch information...
1 parent bbb3135 commit 0c94287ababef5f339297472a42d1f33ded7d687 @mloughran mloughran committed May 6, 2011
Showing with 26 additions and 0 deletions.
  1. +10 −0 CHANGELOG.rdoc
  2. +16 −0 README.md
View
10 CHANGELOG.rdoc
@@ -1,5 +1,15 @@
= Changelog
+== 0.3.0
+
+- new features:
+ - Support WebSocket drafts 05 & 06
+- changes:
+ - Accept request headers in a case insensitive manner
+ - Change handling of errors. Previously some application errors were caught
+ internally and were invisible unless an onerror callback was supplied. See
+ readme for details
+
== 0.2.1 / 2011-03-01
- bugfixes:
View
16 README.md
@@ -42,6 +42,22 @@ For example,
...
end
+## Handling errors
+
+There are two kinds of errors that need to be handled - errors caused by incompatible WebSocket clients sending invalid data and errors in application code. They are handled as follows:
+
+Errors caused by invalid WebSocket data (for example invalid errors in the WebSocket handshake or invalid message frames) raise errors which descend from `EventMachine::WebSocket::WebSocketError`. Such errors are rescued internally and the WebSocket connection will be closed immediately or an error code sent to the browser in accordance to the WebSocket specification. However it is possible to be notified in application code on such errors by including an `onerror` callback.
+
+ ws.onerror { |error|
+ if e.kind_of?(EM::WebSocket::WebSocketError)
+ ...
+ end
+ }
+
+Application errors are treated differently. If no `onerror` callback has been defined these errors will propagate to the EventMachine reactor, typically causing your program to terminate. If you wish to handle exceptions, simply supply an `onerror callback` and check for exceptions which are not decendant from `EventMachine::WebSocket::WebSocketError`.
+
+It is also possible to log all errors when developing by including the `:debug => true` option when initialising the WebSocket connection.
+
## Examples & Projects using em-websocket
* [Pusher](http://pusherapp.com) - Realtime client push

0 comments on commit 0c94287

Please sign in to comment.