feat: ability to delete a project #37
@@ -11,7 +11,7 @@ pub enum Error {
 | 
			
		||||
impl Display for Error {
 | 
			
		||||
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
 | 
			
		||||
        match self {
 | 
			
		||||
| 
					
	
	
	
	
	
	
	
	 | 
			||||
            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> {
 | 
			
		||||
        Ok(match s {
 | 
			
		||||
            "internal server error" => Error::ServerInternal,
 | 
			
		||||
            "internal server error" => Self::ServerInternal,
 | 
			
		||||
            _ => return Err(()),
 | 
			
		||||
        })
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -36,7 +36,7 @@ impl From<ValidationErrors> for ErrorVec<ProjectError> {
 | 
			
		||||
 | 
			
		||||
impl From<diesel::result::Error> for ProjectError {
 | 
			
		||||
    fn from(_: diesel::result::Error) -> Self {
 | 
			
		||||
        ProjectError::Error(Error::ServerInternal)
 | 
			
		||||
        Self::Error(Error::ServerInternal)
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -52,6 +52,6 @@ impl FromStr for ProjectError {
 | 
			
		||||
    type Err = ();
 | 
			
		||||
 | 
			
		||||
    fn from_str(_: &str) -> Result<Self, Self::Err> {
 | 
			
		||||
        Ok(ProjectError::Error(Error::ServerInternal))
 | 
			
		||||
        Ok(Self::Error(Error::ServerInternal))
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -42,12 +42,12 @@ impl From<diesel::result::Error> for TaskError {
 | 
			
		||||
                diesel::result::DatabaseErrorKind::ForeignKeyViolation, info
 | 
			
		||||
            ) => {
 | 
			
		||||
                match info.constraint_name() {
 | 
			
		||||
                    Some("tasks_project_id_fkey") => TaskError::ProjectNotFound,
 | 
			
		||||
                    _ => TaskError::Error(Error::ServerInternal)
 | 
			
		||||
                    Some("tasks_project_id_fkey") => Self::ProjectNotFound,
 | 
			
		||||
                    _ => Self::Error(Error::ServerInternal)
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            _ => {
 | 
			
		||||
                TaskError::Error(Error::ServerInternal)
 | 
			
		||||
                Self::Error(Error::ServerInternal)
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
@@ -65,6 +65,6 @@ impl FromStr for TaskError {
 | 
			
		||||
    type Err = ();
 | 
			
		||||
 | 
			
		||||
    fn from_str(_: &str) -> Result<Self, Self::Err> {
 | 
			
		||||
        Ok(TaskError::Error(Error::ServerInternal))
 | 
			
		||||
        Ok(Self::Error(Error::ServerInternal))
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user
	
Refine error mapping in
Fromimplementation.The current implementation maps all
diesel::result::Errortypes toError::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.