setup for api posting to db
This commit is contained in:
parent
0330876377
commit
308c4fb9c5
4 changed files with 33 additions and 1 deletions
25
src/api/errors.rs
Normal file
25
src/api/errors.rs
Normal 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,
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue