feat: ability to delete a project #37

Merged
matous-volf merged 4 commits from feat/project-delete into main 2024-09-08 06:39:56 +00:00
3 changed files with 8 additions and 8 deletions
Showing only changes of commit 7827d7f722 - Show all commits

View File

@ -11,7 +11,7 @@ pub enum Error {
impl Display for Error { impl Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self { match self {
coderabbitai[bot] commented 2024-09-08 06:25:55 +00:00 (Migrated from github.com)
Review

Refine error mapping in From implementation.

The current implementation maps all diesel::result::Error types to Error::ServerInternal. Consider refining this to differentiate between different types of database errors, such as constraint violations or connection issues, to provide more specific error messages to the client.

**Refine error mapping in `From` implementation.** The current implementation maps all `diesel::result::Error` types to `Error::ServerInternal`. Consider refining this to differentiate between different types of database errors, such as constraint violations or connection issues, to provide more specific error messages to the client. <!-- This is an auto-generated comment by CodeRabbit -->
Error::ServerInternal => write!(f, "internal server error"), Self::ServerInternal => write!(f, "internal server error"),
} }
} }
} }
@ -22,7 +22,7 @@ impl FromStr for Error {
fn from_str(s: &str) -> Result<Self, Self::Err> { fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(match s { Ok(match s {
"internal server error" => Error::ServerInternal, "internal server error" => Self::ServerInternal,
_ => return Err(()), _ => return Err(()),
}) })
} }

View File

@ -36,7 +36,7 @@ impl From<ValidationErrors> for ErrorVec<ProjectError> {
impl From<diesel::result::Error> for ProjectError { impl From<diesel::result::Error> for ProjectError {
fn from(_: diesel::result::Error) -> Self { fn from(_: diesel::result::Error) -> Self {
ProjectError::Error(Error::ServerInternal) Self::Error(Error::ServerInternal)
} }
} }
@ -52,6 +52,6 @@ impl FromStr for ProjectError {
type Err = (); type Err = ();
fn from_str(_: &str) -> Result<Self, Self::Err> { fn from_str(_: &str) -> Result<Self, Self::Err> {
Ok(ProjectError::Error(Error::ServerInternal)) Ok(Self::Error(Error::ServerInternal))
} }
} }

View File

@ -42,12 +42,12 @@ impl From<diesel::result::Error> for TaskError {
diesel::result::DatabaseErrorKind::ForeignKeyViolation, info diesel::result::DatabaseErrorKind::ForeignKeyViolation, info
) => { ) => {
match info.constraint_name() { match info.constraint_name() {
Some("tasks_project_id_fkey") => TaskError::ProjectNotFound, Some("tasks_project_id_fkey") => Self::ProjectNotFound,
_ => TaskError::Error(Error::ServerInternal) _ => Self::Error(Error::ServerInternal)
} }
} }
_ => { _ => {
TaskError::Error(Error::ServerInternal) Self::Error(Error::ServerInternal)
} }
} }
} }
@ -65,6 +65,6 @@ impl FromStr for TaskError {
type Err = (); type Err = ();
fn from_str(_: &str) -> Result<Self, Self::Err> { fn from_str(_: &str) -> Result<Self, Self::Err> {
Ok(TaskError::Error(Error::ServerInternal)) Ok(Self::Error(Error::ServerInternal))
} }
} }