48 lines
1.1 KiB
Rust
48 lines
1.1 KiB
Rust
use std::str::Utf8Error;
|
|
|
|
use async_trait::async_trait;
|
|
use fluffer::GemBytes;
|
|
use thiserror::Error;
|
|
|
|
use crate::validation::c2s::C2SValidationError;
|
|
|
|
#[derive(Error, Debug)]
|
|
pub(crate) enum GementionError {
|
|
#[error("No content found for target")]
|
|
NoContentFoundForTarget,
|
|
|
|
#[error("Not a Titan resource")]
|
|
NotTitanResource,
|
|
|
|
#[error("Invalid mention type: {0}")]
|
|
InvalidMentionType(String),
|
|
|
|
#[error("Invalid body")]
|
|
InvalidBody,
|
|
|
|
#[error("Gemention Target not provided")]
|
|
TargetNotProvided,
|
|
|
|
#[error("Username not provided")]
|
|
UsernameNotProvided,
|
|
|
|
#[error("url parsing error: {0}")]
|
|
UrlParsingError(#[from] url::ParseError),
|
|
|
|
#[error("value was not utf8: {0}")]
|
|
Utf8Error(#[from] Utf8Error),
|
|
|
|
#[error("c2s validation error: {0}")]
|
|
C2SValidationError(#[from] C2SValidationError),
|
|
|
|
#[error("generic error: {0}")]
|
|
UnclassifiedError(#[from] anyhow::Error),
|
|
}
|
|
|
|
#[async_trait]
|
|
impl GemBytes for GementionError {
|
|
async fn gem_bytes(self) -> Vec<u8> {
|
|
format!("59 text/gemini\r\n{}", self).into_bytes()
|
|
}
|
|
}
|