mirror of https://github.com/Trivernis/nenv
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
470 B
Rust
26 lines
470 B
Rust
1 year ago
|
use std::io;
|
||
|
|
||
|
use lazy_static::__Deref;
|
||
|
use miette::Diagnostic;
|
||
|
use thiserror::Error;
|
||
|
|
||
|
pub type ApiResult<T> = Result<T, ApiError>;
|
||
|
|
||
|
#[derive(Debug, Error, Diagnostic)]
|
||
|
pub enum ApiError {
|
||
|
#[error(transparent)]
|
||
|
Reqwest(#[from] reqwest::Error),
|
||
|
|
||
|
#[error(transparent)]
|
||
|
Io(#[from] io::Error),
|
||
|
|
||
|
#[error("{0}")]
|
||
|
Other(#[help] String),
|
||
|
}
|
||
|
|
||
|
impl ApiError {
|
||
|
pub fn other<S: ToString>(error: S) -> Self {
|
||
|
Self::Other(error.to_string())
|
||
|
}
|
||
|
}
|