/
basuev
/
gverse
Обзор
Документация
Войти
/
basuev
/
gverse
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/error.rs
43 строки
1 KB
basuev
initial commit: gverse v0.1.0
27 май 2026, 08:52
27 май 2026, 08:52
98b24dd
Код
Авторство
О чём код?
use thiserror::Error; #[derive(Debug, Error)] pub enum Error { #[error("not authenticated; run `gverse auth login --token <TOKEN>`")] NotAuthenticated, #[error("profile `{0}` not found in config")] UnknownProfile(String), #[error("API error {status}: {message}")] Api { status: u16, message: String }, #[error("rate limit exceeded; retry after {retry_after}s")] RateLimited { retry_after: u64 }, #[error("io: {0}")] Io(#[from] std::io::Error), #[error("http: {0}")] Http(#[from] reqwest::Error), #[error("config parse: {0}")] ConfigParse(#[from] toml::de::Error), #[error("config write: {0}")] ConfigWrite(#[from] toml::ser::Error), #[error("json: {0}")] Json(#[from] serde_json::Error), #[error("invalid value: {0}")] Invalid(String), } pub type Result<T> = std::result::Result<T, Error>; impl Error { pub fn exit_code(&self) -> u8 { match self { Self::Invalid(_) => 2, Self::NotAuthenticated | Self::UnknownProfile(_) | Self::Api { status: 401 | 403, .. } => 3, Self::Api { status: 404, .. } => 4, Self::RateLimited { .. } => 5, _ => 1, } } }