feat: ability to create a task #14

Merged
matous-volf merged 12 commits from feat/task-create into main 2024-08-22 21:40:47 +00:00
2 changed files with 10 additions and 10 deletions
Showing only changes of commit c107525eb7 - Show all commits

View File

@ -12,8 +12,8 @@ pub enum ProjectCreateError {
}
impl From<ValidationErrors> for ErrorVec<ProjectCreateError> {
fn from(e: ValidationErrors) -> Self {
e.errors()
fn from(validation_errors: ValidationErrors) -> Self {
validation_errors.errors()
.iter()
.flat_map(|(&field, error_kind)| match field {
"title" => match error_kind {
@ -34,18 +34,18 @@ impl From<ValidationErrors> for ErrorVec<ProjectCreateError> {
}
}
// has to be implemented for Dioxus server functions
// Has to be implemented for Dioxus server functions.
impl Display for ProjectCreateError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self)
}
}
// has to be implemented for Dioxus server functions
// Has to be implemented for Dioxus server functions.
coderabbitai[bot] commented 2024-08-22 20:20:54 +00:00 (Migrated from github.com)
Review

Consider alternatives to panic for unexpected validation errors.

Using panic for unexpected validation errors may not be ideal in production code. Consider logging the error and returning a default error variant or using a custom error type.

**Consider alternatives to panic for unexpected validation errors.** Using panic for unexpected validation errors may not be ideal in production code. Consider logging the error and returning a default error variant or using a custom error type. <!-- This is an auto-generated comment by CodeRabbit -->
impl FromStr for ProjectCreateError {
type Err = ();
fn from_str(_: &str) -> Result<Self, Self::Err> {
Ok(ProjectCreateError::TitleLengthInvalid)
Ok(ProjectCreateError::Error(Error::ServerInternal))
}
}

View File

@ -13,8 +13,8 @@ pub enum TaskCreateError {
}
impl From<ValidationErrors> for ErrorVec<TaskCreateError> {
fn from(e: ValidationErrors) -> Self {
e.errors()
fn from(validation_errors: ValidationErrors) -> Self {
validation_errors.errors()
.iter()
.flat_map(|(&field, error_kind)| match field {
"title" => match error_kind {
@ -35,18 +35,18 @@ impl From<ValidationErrors> for ErrorVec<TaskCreateError> {
}
}
// has to be implemented for Dioxus server functions
// Has to be implemented for Dioxus server functions.
impl Display for TaskCreateError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self)
}
}
// has to be implemented for Dioxus server functions
// Has to be implemented for Dioxus server functions.
impl FromStr for TaskCreateError {
type Err = ();
fn from_str(_: &str) -> Result<Self, Self::Err> {
Ok(TaskCreateError::TitleLengthInvalid)
Ok(TaskCreateError::Error(Error::ServerInternal))
}
}