feat: add repo importing
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
use actix_web::{HttpResponse, ResponseError, http::StatusCode};
|
||||
use aws_sdk_dynamodb::error::SdkError;
|
||||
use serde::Serialize;
|
||||
use thiserror::Error;
|
||||
|
||||
@@ -18,6 +19,16 @@ pub enum Error {
|
||||
Jwx(#[from] jsonwebtoken::errors::Error),
|
||||
#[error("token expired")]
|
||||
TokenExpired,
|
||||
#[error("dynamodb error: {0}")]
|
||||
DynamoDB(String),
|
||||
#[error("item already exists")]
|
||||
AlreadyExists,
|
||||
}
|
||||
|
||||
impl<E: std::fmt::Debug> From<SdkError<E>> for Error {
|
||||
fn from(err: SdkError<E>) -> Self {
|
||||
Error::DynamoDB(format!("{:?}", err))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
@@ -33,6 +44,9 @@ impl ResponseError for Error {
|
||||
Error::TokenExpired => HttpResponse::Unauthorized().json(ErrorResponse {
|
||||
error: "token expired".to_string(),
|
||||
}),
|
||||
Error::AlreadyExists => HttpResponse::BadRequest().json(ErrorResponse {
|
||||
error: "item already exists".to_string(),
|
||||
}),
|
||||
_ => HttpResponse::InternalServerError().finish(),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user