migration_helpers/
migration_helpers.rs1use quarto_error_reporting::{generic_error, generic_warning};
8
9fn main() {
10 println!("=== Example 1: Using generic_error! macro ===\n");
11
12 let error = generic_error!("Something went wrong during migration");
17
18 println!("{}", error.to_text(None));
19 println!();
20
21 println!("Error code: {:?}", error.code);
23 println!();
24
25 println!("=== Example 2: Using generic_warning! macro ===\n");
26
27 let warning = generic_warning!("This feature is not yet fully migrated");
28
29 println!("{}", warning.to_text(None));
30 println!();
31
32 println!("=== Example 3: Migration pattern in practice ===\n");
33
34 let path = "/nonexistent/file.qmd";
53 let migration_error = generic_error!(format!("File not found: {}", path));
54
55 println!("Migration-style error:");
56 println!("{}", migration_error.to_text(None));
57 println!();
58
59 println!("=== Example 4: JSON output shows file/line info ===\n");
60
61 let error_with_location = generic_error!("Error with source tracking");
62 let json = error_with_location.to_json();
63
64 println!("{}", serde_json::to_string_pretty(&json).unwrap());
65 println!();
66
67 println!("Note: The generic_error! and generic_warning! macros are intended");
68 println!("for migration purposes only. New code should use DiagnosticMessageBuilder");
69 println!("with proper error codes (Q-X-Y) instead of Q-0-99.");
70}