wapc_pool/
errors.rs

1//! Library-specific error types and utility functions
2
3/// Error type for this crate.
4#[derive(Debug, thiserror::Error)]
5pub enum Error {
6  /// Error returned when we failed to receive a return from a worker.
7  #[error("Request failed: {0}")]
8  RequestFailed(String),
9
10  /// Error returned when trying to shutdown a pool that's uninitialized or already shut down.
11  #[error("No pool available. Have you initialized the HostPool or already shut it down?")]
12  NoPool,
13}
14
15impl From<Error> for wapc::errors::Error {
16  fn from(e: Error) -> Self {
17    wapc::errors::Error::General(e.to_string())
18  }
19}
20
21#[cfg(test)]
22mod tests {
23  #[allow(dead_code)]
24  fn needs_sync_send<T: Send + Sync>() {}
25
26  #[test]
27  fn assert_sync_send() {
28    needs_sync_send::<super::Error>();
29  }
30}