Permalink
Browse files

better websocket error handling

  • Loading branch information...
1 parent d686da7 commit 2e67c68f9d0f124ce5f186d24be976e0ba621bf7 @asmuth committed Mar 5, 2013
@@ -22,8 +22,12 @@ def execute(*args)
private
def execute_unsafe(socket, event, messages = [])
- return false unless event["namespace"]
- return false unless ns = @namespaces[event["namespace"].to_sym]
+ return [] unless event["namespace"]
+
+ unless ns = @namespaces[event["namespace"].to_sym]
+ return([{ "error" => "invalid namespace: #{event["namespace"]}" }])
+ end
+
messages << discover(ns) if event["type"] == "discover_request"
messages << widget(ns, event) if event["type"] == "widget_request"
messages << gauge(ns, event) if event["type"] == "render_request"
@@ -29,6 +29,9 @@ def on_message(env, message)
send_data m.to_json
end
end
+ rescue Exception => e
+ FnordMetric.error("[WebSocket] #{e.to_s}")
+ puts e.backtrace.join("\n")
end
def get_uuid

0 comments on commit 2e67c68

Please sign in to comment.