Implemented roll request, updated API requests

This commit is contained in:
2024-12-20 15:13:31 -05:00
parent bb03654d5f
commit 8ac0e59b8c
23 changed files with 459 additions and 150 deletions

View File

@@ -1,6 +1,6 @@
use std::fmt;
use axum::http::StatusCode;
use axum::Json;
use axum::{http, Json};
use axum::response::{IntoResponse, Response};
use serde::{Deserialize, Serialize};
@@ -13,12 +13,20 @@ pub struct Error {
}
impl Error {
pub fn new(error_status_code: u16, error_message: String) -> Self {
pub fn new(status: u16, details: String) -> Self {
Self {
status: error_status_code,
details: error_message,
status,
details,
}
}
pub fn not_found(details: String) -> Self {
Self::new(404, details)
}
pub fn internal_server_error(details: String) -> Self {
Self::new(500, details)
}
}
impl fmt::Display for Error {
@@ -56,6 +64,12 @@ impl From<std::io::Error> for Error {
}
}
impl From<songbird::tracks::ControlError> for Error {
fn from(error: songbird::tracks::ControlError) -> Self {
Self::new(500, format!("Unknown control error: {}", error))
}
}
impl From<StatusCode> for Error {
fn from(status: StatusCode) -> Self {
Error {