Skip to main content

ppt_rs/exc/
messages.rs

1//! Unified error message formatting for consistent diagnostics across modules.
2
3/// Missing required package part.
4pub fn missing_part(path: &str) -> String {
5    format!("Missing required part: {path}")
6}
7
8/// Slide index not found in presentation.
9pub fn slide_not_found(index: usize) -> String {
10    format!("Slide {index} not found")
11}
12
13/// Slide part file missing from package.
14pub fn slide_file_not_found(path: &str) -> String {
15    format!("Slide file not found: {path}")
16}
17
18/// Generic index out of range message.
19pub fn index_out_of_range(field: &str, index: usize, count: usize) -> String {
20    format!("{field} index {index} out of range (count: {count})")
21}
22
23/// Field must not be empty.
24pub fn must_not_be_empty(field: &str) -> String {
25    format!("{field} must not be empty")
26}
27
28/// Field must be a positive value.
29pub fn must_be_positive(field: &str) -> String {
30    format!("{field} must be positive")
31}
32
33/// Empty XML document or part.
34pub fn empty_xml(path: &str) -> String {
35    format!("Empty XML content in '{path}'")
36}
37
38/// Empty XML without a specific path.
39pub fn empty_xml_content() -> String {
40    "Empty XML content".to_string()
41}
42
43/// Malformed XML in a specific part.
44pub fn invalid_xml(path: &str, detail: &str) -> String {
45    format!("Invalid XML in '{path}': {detail}")
46}
47
48/// Unsupported file or media format.
49pub fn unsupported_format(ext: &str) -> String {
50    format!("Unsupported format: {ext}")
51}
52
53/// Unsupported media format with extension context.
54pub fn unsupported_media_format(ext: &str) -> String {
55    format!("Unsupported media format: {ext}")
56}
57
58/// Invalid value with field context.
59pub fn invalid_value(field: &str, detail: &str) -> String {
60    format!("Invalid {field}: {detail}")
61}
62
63/// Operation not supported for this element type.
64pub fn unsupported_operation(element: &str, operation: &str) -> String {
65    format!("{operation} is not supported for {element}")
66}
67
68/// External command execution failure.
69pub fn command_failed(command: &str, detail: &str) -> String {
70    format!("Failed to execute {command}: {detail}")
71}
72
73/// External command returned a non-success status.
74pub fn command_unsuccessful(command: &str) -> String {
75    format!("{command} failed")
76}
77
78/// Expected output file was not produced.
79pub fn output_not_found(path: &str) -> String {
80    format!("Output file not found: {path}")
81}