use actix::MailboxError;
use std::io;
use tokio::timer;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("internal gWasm API error: {0}")]
MailboxError(#[from] MailboxError),
#[error("internal gWasm API error: {0}")]
TimerError(#[from] timer::Error),
#[error("internal gWasm API error: {0}")]
IOError(#[from] io::Error),
#[error("internal Golem error: {0}")]
WampError(actix_wamp::Error),
#[error("internal Golem error: {0}")]
GolemRPCError(golem_rpc_api::Error),
#[error("received Ctrl-C interrupt")]
KeyboardInterrupt(tokio_ctrlc_error::KeyboardInterrupt),
#[error("internal gWasm API error: {0}")]
CtrlcError(tokio_ctrlc_error::IoError),
#[error("error parsing Timeout value: {0}")]
ChronoError(#[from] chrono::ParseError),
#[error("zero timeout \"00:00:00\" is forbidden")]
ZeroTimeoutError,
#[error("empty TaskInfo received from Golem")]
EmptyTaskInfo,
#[error("empty progress in TaskInfo")]
EmptyProgress,
#[error("task aborted externally")]
TaskAborted,
#[error("task timed out")]
TaskTimedOut,
}
impl From<actix_wamp::Error> for Error {
fn from(err: actix_wamp::Error) -> Self {
Error::WampError(err)
}
}
impl From<golem_rpc_api::Error> for Error {
fn from(err: golem_rpc_api::Error) -> Self {
Error::GolemRPCError(err)
}
}
impl From<tokio_ctrlc_error::IoError> for Error {
fn from(err: tokio_ctrlc_error::IoError) -> Self {
Error::CtrlcError(err)
}
}
impl From<tokio_ctrlc_error::KeyboardInterrupt> for Error {
fn from(err: tokio_ctrlc_error::KeyboardInterrupt) -> Self {
Error::KeyboardInterrupt(err)
}
}