Implemented roll request, updated API requests
This commit is contained in:
22
src/error.rs
22
src/error.rs
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user