1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
//! Domain error models and result types for the MoonGraphQL Builder framework.
//!
//! Encapsulates schema budget violations (AST query complexity and tree nesting depth)
//! alongside preemptive client-side parameter validation errors, backed by
//! Project Fluent multi-locale string interpolation.
//!
//! ### Error Philosophy: Fail Fast & Preemptively
//!
//! Rather than allowing invalid arguments or overly complex queries to reach the remote
//! GraphQL server (only to fail with expensive HTTP `422` or `429` errors), [`MoongqlError`]
//! detects schema constraint violations **locally in memory**, saving bandwidth and rate-limiting quotas.
//!
//! ### Quick Example
//!
//! ```rust
//! use moongraphql_builder::prelude::*;
//!
//! fn handle_graphql_error(err: MoongqlError) {
//! match err {
//! MoongqlError::ComplexityExceeded { calculated, limit } => {
//! eprintln!("Query too expensive! Cost: {} (Max allowed: {})", calculated, limit);
//! }
//! MoongqlError::DepthExceeded { calculated, limit } => {
//! eprintln!("Query too deeply nested! Depth: {} (Max allowed: {})", calculated, limit);
//! }
//! MoongqlError::ValidationError(details) => {
//! eprintln!("Preemptive argument validation failed: {}", details);
//! }
//! }
//! }
//! ```
use Error;
/// Primary error type for the `moongraphql_builder` framework.
///
/// Provides automated, localized diagnostic descriptions resolved dynamically via Project Fluent.
/// Ergonomic type alias for [`std::result::Result`] specialized over [`MoongqlError`].
///
/// Used throughout builder validation routines, metric evaluators, and payload compilers.
///
/// # Example
///
/// ```rust
/// use moongraphql_builder::error::{MoongqlError, Result};
///
/// fn verify_complexity(calculated: u32, max_limit: u32) -> Result<()> {
/// if calculated > max_limit {
/// return Err(MoongqlError::ComplexityExceeded {
/// calculated,
/// limit: max_limit,
/// });
/// }
/// Ok(())
/// }
/// ```
pub type Result<T> = Result;