Messages
Errors are not mere interruptions in the execution flow or technical glitches; they are considered as significant domain concepts that convey essential information about the business process. These errors can range from simple validation failures to complex business rule violations, each carrying context-specific information critical to the understanding and resolution of issues.
Creating Errors
Errors represent violation of business rules. They should have meaningful names and be as descriptive as possible.
domain/src/todolist_error.rs
use framework::*;
use crate::todolist_scalar::TaskIndex;
#[derive(Debug, PartialEq, Error)]
pub enum TodoListError {
#[error("Task already completed")]
TaskAlreadyCompleted(TaskIndex),
#[error("Task index out of bounds")]
TaskNotFound(TaskIndex),
}