setup for api posting to db

This commit is contained in:
Chris Cochrun 2024-06-25 06:51:22 -05:00
parent 0330876377
commit 308c4fb9c5
4 changed files with 33 additions and 1 deletions

25
src/api/errors.rs Normal file
View file

@ -0,0 +1,25 @@
use serde::Serialize;
#[derive(Debug)]
pub enum ApiErrorType {
DbError,
NotFoundError,
}
impl Default for ApiErrorType {
fn default() -> ApiErrorType {
ApiErrorType::NotFoundError
}
}
#[derive(Debug, Default)]
pub struct ApiError {
pub message: Option<String>,
pub cause: Option<String>,
pub error_type: ApiErrorType,
}
#[derive(Serialize)]
pub struct ApiErrorResponse {
pub error: String,
}