diff --git a/Source/SocketAckEmitter.swift b/Source/SocketAckEmitter.swift index 6ec5e5f..cdff4a8 100644 --- a/Source/SocketAckEmitter.swift +++ b/Source/SocketAckEmitter.swift @@ -48,11 +48,18 @@ public final class SocketAckEmitter : NSObject { /// Call to ack receiving this event. /// + /// If an error occurs trying to transform `items` into their socket representation, a `SocketClientEvent.error` + /// will be emitted. The structure of the error data is `[ackNum, items, theError]` + /// /// - parameter items: A variable number of items to send when acking. public func with(_ items: SocketData...) { guard ackNum != -1 else { return } - socket.emitAck(ackNum, with: items) + do { + socket.emitAck(ackNum, with: try items.map({ try $0.socketRepresentation() })) + } catch let err { + socket.handleClientEvent(.error, data: [ackNum, items, err]) + } } /// Call to ack receiving this event.