         do {
             try send(JSON(["type": "ping"]))
         } catch let error {
-            //TODO: better
-            print("ping failed: \(error)")
+            handleError(EventBusError.unknownError(error: error))
         }
     }
 
     func uuid() -> String {
         return NSUUID().uuidString
     }
-    
+
     public func send(to address: String,
                      message: [String: Any],
                      headers: [String: String]? = nil,
                      callback: ((JSON) -> ())? = nil) throws {
         var msg: [String: Any] = ["type": "send", "address": address, "body": message, "headers": headers ?? [String: String]()]
-        
+
         if let cb = callback {
             let replyAddress = uuid()
             replyHandlers[replyAddress] = {[unowned self] m in

            }
        } else if let h = self.replyHandlers[address] {
            workQueue.async(execute: { h(json) })
        } else {
            print("no handlers for \(address), ignoring: \(json)")
        }
    }
    
    func send(_ message: JSON) throws {
        try Util.write(from: message, to: self.socket)
    }
    
    func send(_ message: String) throws {
        try Util.write(from: message, to: self.socket)
    }

    public func unregister(address: String, id: String) throws -> Bool {
        guard var handlers = self.handlers[address],
              let _ = handlers[id] else {

                  return false
              }

        handlers.removeValue(forKey: id)

        if handlers.isEmpty {
            try send(JSON(["type": "unregister", "address": address])) //TODO: headers
        }

        return true
    }

    public func register(errorHandler: @escaping (EventBusError) -> ()) {
        self.errorHandler = errorHandler
    }


    public func close() {
        if self.open {
            self.socket.close()
