     }
 }
 
-enum MessageError: Error {
-    case unsupported
+public enum ChannelError: Error {
+    case messageUnsupported
+    case closed
 }

    }
    
    override fileprivate func writeToSocket(pendingWrites: PendingWrites) throws -> Bool? {
        pendingWrites.failAll(error: MessageError.unsupported)
        return true
    }
    


    func write0(data: Any, promise: Promise<Void>) {
        guard open else {
            // Channel was already closed, fail the promise and not even queue it.
            promise.fail(error: ChannelError.closed)
            return
        }
        if let buffer = data as? ByteBuffer {
            pendingWrites.add(buffer: buffer, promise: promise)
        } else {
            // Only support ByteBuffer for now. 
            promise.fail(error: ChannelError.messageUnsupported)
        }
    }

