LD-KickWatch/src-tauri/src/error.rs

44 lines
1 KiB
Rust
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

use serde::Serialize;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum AppError {
#[error("Ağ hatası: {0}")]
Network(#[from] reqwest::Error),
#[error("JSON serileştirme hatası: {0}")]
Serialization(#[from] serde_json::Error),
#[error("Dosya G/Ç hatası: {0}")]
Io(#[from] std::io::Error),
#[error("WebSocket hatası: {0}")]
WebSocket(String),
#[error("Kanal bulunamadı: {0}")]
ChannelNotFound(String),
#[error("Oynatıcı bulunamadı: {0}")]
PlayerNotFound(String),
#[error("Geçersiz işlem veya parametre: {0}")]
InvalidInput(String),
#[error("Ses çalma hatası: {0}")]
Audio(String),
#[error("Yayın akışına erişilemedi: {0}")]
StreamUnavailable(String),
#[error("Bilinmeyen sistem hatası: {0}")]
General(String),
}
impl Serialize for AppError {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_str(&self.to_string())
}
}