Added Location and location ownership/rights to gamenight.
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
use actix_web::{
|
||||
error::BlockingError,
|
||||
http::{header::ContentType, StatusCode},
|
||||
HttpResponse, ResponseError,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt::{Display, Formatter, Result};
|
||||
use actix_web::{ResponseError, error::BlockingError, HttpResponse, http::{header::ContentType, StatusCode}};
|
||||
use serde::{Serialize, Deserialize};
|
||||
use validator::ValidationErrors;
|
||||
|
||||
use gamenight_database::error::DatabaseError;
|
||||
@@ -9,7 +13,7 @@ use gamenight_database::error::DatabaseError;
|
||||
pub struct ApiError {
|
||||
#[serde(skip_serializing)]
|
||||
pub status: u16,
|
||||
pub message: String
|
||||
pub message: String,
|
||||
}
|
||||
|
||||
impl Display for ApiError {
|
||||
@@ -21,9 +25,9 @@ impl Display for ApiError {
|
||||
impl ResponseError for ApiError {
|
||||
fn error_response(&self) -> HttpResponse {
|
||||
HttpResponse::build(StatusCode::from_u16(self.status).unwrap())
|
||||
.content_type(ContentType::json())
|
||||
.body(serde_json::to_string(&self).unwrap())
|
||||
}
|
||||
.content_type(ContentType::json())
|
||||
.body(serde_json::to_string(&self).unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<DatabaseError> for ApiError {
|
||||
@@ -31,7 +35,7 @@ impl From<DatabaseError> for ApiError {
|
||||
ApiError {
|
||||
//Todo, split this in unrecoverable and schema error
|
||||
status: 500,
|
||||
message: value.0
|
||||
message: value.0,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,7 +44,7 @@ impl From<BlockingError> for ApiError {
|
||||
fn from(value: BlockingError) -> Self {
|
||||
ApiError {
|
||||
status: 500,
|
||||
message: value.to_string()
|
||||
message: value.to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,7 +53,7 @@ impl From<serde_json::Error> for ApiError {
|
||||
fn from(value: serde_json::Error) -> Self {
|
||||
ApiError {
|
||||
status: 500,
|
||||
message: value.to_string()
|
||||
message: value.to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -58,7 +62,7 @@ impl From<jsonwebtoken::errors::Error> for ApiError {
|
||||
fn from(value: jsonwebtoken::errors::Error) -> Self {
|
||||
ApiError {
|
||||
status: 500,
|
||||
message: value.to_string()
|
||||
message: value.to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -67,7 +71,7 @@ impl From<ValidationErrors> for ApiError {
|
||||
fn from(value: ValidationErrors) -> Self {
|
||||
ApiError {
|
||||
status: 422,
|
||||
message: value.to_string()
|
||||
message: value.to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -76,7 +80,7 @@ impl From<chrono::ParseError> for ApiError {
|
||||
fn from(value: chrono::ParseError) -> Self {
|
||||
ApiError {
|
||||
status: 422,
|
||||
message: value.to_string()
|
||||
message: value.to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,7 +89,7 @@ impl From<uuid::Error> for ApiError {
|
||||
fn from(value: uuid::Error) -> Self {
|
||||
ApiError {
|
||||
status: 422,
|
||||
message: value.to_string()
|
||||
message: value.to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user