style: fix the rustfmt linted files
Some checks failed
actionlint check / actionlint check (pull_request) Successful in 5s
checkov check / checkov check (pull_request) Successful in 52s
conventional commit messages check / conventional commit messages check (pull_request) Successful in 4s
conventional pull request title check / conventional pull request title check (pull_request) Successful in 2s
dotenv-linter check / dotenv-linter check (pull_request) Successful in 5s
GitLeaks check / GitLeaks check (pull_request) Successful in 6s
hadolint check / hadolint check (pull_request) Successful in 7s
htmlhint check / htmlhint check (pull_request) Successful in 9s
markdownlint check / markdownlint check (pull_request) Successful in 9s
Prettier check / Prettier check (pull_request) Successful in 10s
Rust check / Rust check (pull_request) Failing after 6m20s
ShellCheck check / ShellCheck check (pull_request) Successful in 12s
Stylelint check / Stylelint check (pull_request) Successful in 11s
yamllint check / yamllint check (pull_request) Successful in 13s

This commit is contained in:
2024-12-29 19:30:35 +01:00
parent 149451cc77
commit 3646aa91c4
47 changed files with 393 additions and 296 deletions

View File

@ -8,8 +8,8 @@ pub enum Error {
}
impl From<diesel::result::Error> for Error {
fn from(_: diesel::result::Error) -> Self {
Self::ServerInternal
fn from(_: diesel::result::Error) -> Self {
Self::ServerInternal
}
}

View File

@ -1,7 +1,7 @@
use std::fmt::Display;
use std::str::FromStr;
use serde::Deserialize;
use serde_with::serde_derive::Serialize;
use std::fmt::Display;
use std::str::FromStr;
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct ErrorVec<T> {

View File

@ -1,5 +1,5 @@
pub(crate) mod error;
pub(crate) mod error_vec;
pub(crate) mod project_error;
pub(crate) mod task_error;
pub(crate) mod subtask_error;
pub(crate) mod task_error;

View File

@ -13,7 +13,8 @@ pub enum ProjectError {
impl From<ValidationErrors> for ErrorVec<ProjectError> {
fn from(validation_errors: ValidationErrors) -> Self {
validation_errors.errors()
validation_errors
.errors()
.iter()
.flat_map(|(&field, error_kind)| match field {
"title" => match error_kind {

View File

@ -14,7 +14,8 @@ pub enum SubtaskError {
impl From<ValidationErrors> for ErrorVec<SubtaskError> {
fn from(validation_errors: ValidationErrors) -> Self {
validation_errors.errors()
validation_errors
.errors()
.iter()
.flat_map(|(&field, error_kind)| match field {
"title" => match error_kind {
@ -39,24 +40,24 @@ impl From<diesel::result::Error> for SubtaskError {
fn from(diesel_error: diesel::result::Error) -> Self {
match diesel_error {
diesel::result::Error::DatabaseError(
diesel::result::DatabaseErrorKind::ForeignKeyViolation, info
) => {
match info.constraint_name() {
Some("subtasks_task_id_fkey") => Self::TaskNotFound,
_ => Self::Error(Error::ServerInternal)
}
}
_ => {
Self::Error(Error::ServerInternal)
}
diesel::result::DatabaseErrorKind::ForeignKeyViolation,
info,
) => match info.constraint_name() {
Some("subtasks_task_id_fkey") => Self::TaskNotFound,
_ => Self::Error(Error::ServerInternal),
},
_ => Self::Error(Error::ServerInternal),
}
}
}
impl From<ErrorVec<Error>> for ErrorVec<SubtaskError> {
fn from(error_vec: ErrorVec<Error>) -> Self {
Vec::from(error_vec).into_iter()
.map(SubtaskError::Error).collect::<Vec<SubtaskError>>().into()
Vec::from(error_vec)
.into_iter()
.map(SubtaskError::Error)
.collect::<Vec<SubtaskError>>()
.into()
}
}

View File

@ -14,7 +14,8 @@ pub enum TaskError {
impl From<ValidationErrors> for ErrorVec<TaskError> {
fn from(validation_errors: ValidationErrors) -> Self {
validation_errors.errors()
validation_errors
.errors()
.iter()
.flat_map(|(&field, error_kind)| match field {
"title" => match error_kind {
@ -39,16 +40,13 @@ impl From<diesel::result::Error> for TaskError {
fn from(diesel_error: diesel::result::Error) -> Self {
match diesel_error {
diesel::result::Error::DatabaseError(
diesel::result::DatabaseErrorKind::ForeignKeyViolation, info
) => {
match info.constraint_name() {
Some("tasks_project_id_fkey") => Self::ProjectNotFound,
_ => Self::Error(Error::ServerInternal)
}
}
_ => {
Self::Error(Error::ServerInternal)
}
diesel::result::DatabaseErrorKind::ForeignKeyViolation,
info,
) => match info.constraint_name() {
Some("tasks_project_id_fkey") => Self::ProjectNotFound,
_ => Self::Error(Error::ServerInternal),
},
_ => Self::Error(Error::ServerInternal),
}
}
}