molten_service/error.rs
1//! Defines error types specific to service orchestration within the `molten-service` crate.
2//!
3//! This module provides a comprehensive set of error variants encapsulated by
4//! `ServiceError`, each detailing specific reasons why a service failed.
5use molten_document::DocumentValidationError;
6use molten_workflow::WorkflowError;
7use thiserror::Error;
8
9/// Represents errors that can occur within the Molten service layer.
10#[derive(Error, Debug)]
11pub enum ServiceError {
12 /// An error occurred during a database operation.
13 #[error("Database error: {0}")]
14 DatabaseError(#[from] sea_orm::DbErr),
15
16 /// A requested form definition was not found.
17 #[error("Form definition not found: {0}")]
18 FormNotFound(String),
19
20 /// A requested workflow definition was not found.
21 #[error("Workflow definition not found: {0}")]
22 WorkflowNotFound(String),
23
24 /// Document validation failed, returning a list of specific errors.
25 #[error("Document validation failed: {0:?}")]
26 DocumentValidationErrors(Vec<DocumentValidationError>),
27
28 /// Form validation failed, returning a detailed error structure.
29 #[error("Form validation failed: {0:?}")]
30 FormValidationErrors(validator::ValidationErrors),
31
32 /// Workflow validation failed, returning a detailed error structure.
33 #[error("Workflow validation failed: {0:?}")]
34 WorkflowValidationErrors(validator::ValidationErrors),
35
36 /// A rule defined in a workflow was violated.
37 #[error("Workflow violation: {0}")]
38 WorkflowRuleViolation(#[from] WorkflowError),
39
40 /// An unexpected internal error occurred.
41 #[error("Internal error: {0}")]
42 Internal(#[from] anyhow::Error),
43}