1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#![allow(missing_docs)]

use std::io;

use crate::ws;

error_chain! {
	foreign_links {
		Io(io::Error);
	}

	errors {
		/// Attempted action on closed connection.
		ConnectionClosed {
			description("connection is closed"),
			display("Action on closed connection."),
		}
	}
}

impl From<ws::Error> for Error {
	fn from(err: ws::Error) -> Self {
		match err.kind {
			ws::ErrorKind::Io(e) => e.into(),
			_ => Error::with_chain(err, "WebSockets Error"),
		}
	}
}