 
     func write0(data: Any, promise: Promise<Void>) {
         guard open else {
-            // Channel was already closed to fail the promise and not even queue it.
-            promise.fail(error: IOError(errno: EBADF, reason: "Channel closed"))
+            // 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: MessageError.unsupported)
+            promise.fail(error: ChannelError.messageUnsupported)
         }
     }
 

        }
    }
    
    func close0(promise: Promise<Void> = Promise<Void>(), error: Error = IOError(errno: EBADF, reason: "Channel closed")) {
        guard open else {            

            // Already closed

    }
}

public enum ChannelError: Error {
    case messageUnsupported
    case closed
}
