homestar_runtime/cli/
error.rs1use crate::network::rpc;
4use miette::{miette, Diagnostic};
5use std::io;
6use tarpc::client::RpcError;
7
8#[derive(thiserror::Error, Debug, Diagnostic)]
10pub enum Error {
11 #[error("{error_message}")]
13 Cli {
14 error_message: String,
16 },
17 #[error(transparent)]
19 Rpc(#[from] RpcError),
20 #[error(transparent)]
22 RpcMessage(#[from] rpc::Error),
23 #[error("error writing data to console: {0}")]
25 Io(#[from] io::Error),
26}
27
28impl Error {
29 pub fn new(err: miette::ErrReport) -> Self {
31 Error::Cli {
32 error_message: err.to_string(),
33 }
34 }
35}
36
37impl From<anyhow::Error> for Error {
38 fn from(e: anyhow::Error) -> Self {
39 Error::new(miette!(e.to_string()))
40 }
41}