/*
 * Copyright (c) 2025, LJason. All Rights Reserved.
 */

use std::{
    error::Error,
    fmt::{Display, Formatter, Result},
};

/// `BiliCore` 库的错误类型
#[derive(Debug)]
pub enum BiCoreError {
    /// 请求错误
    RequestError(String),
    /// 访问权限不足
    AccessDenied,
    /// 缺少 Data
    MissingData,
    /// 解析错误
    ParseError(String),
    /// 未知错误
    Unknown,
}

impl Error for BiCoreError {}

impl Display for BiCoreError {
    fn fmt(&self, f: &mut Formatter<'_>) -> Result {
        match self {
            BiCoreError::RequestError(e) => write!(f, "{e}"),
            BiCoreError::AccessDenied => f.write_str("访问权限不足"),
            BiCoreError::MissingData => f.write_str("缺少 Data"),
            BiCoreError::ParseError(e) => write!(f, "解析错误: {e}"),
            BiCoreError::Unknown => f.write_str("未知错误"),
        }
    }
}
