Skip to content

Commit 1b056e4

Browse files
authored
Merge pull request #13 from gripmock/errors-details
add support errdetails
2 parents c7462ff + 506977b commit 1b056e4

File tree

7 files changed

+723
-28
lines changed

7 files changed

+723
-28
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
resolver = "2"
33

44
[workspace.package]
5-
version = "1.4.0"
5+
version = "1.4.1"
66
edition = "2024"
77
authors = ["bavix"]
88
license = "MIT"

src/commands/explain.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,31 @@ fn print_detailed_workflow(
364364
if let Some(message) = value.get("message") {
365365
println!(" Message: {}", message);
366366
}
367+
if let Some(details) = value.get("details") {
368+
println!(" Details: required (strict match)");
369+
if let Some(items) = details.as_array() {
370+
println!(" Details Count: {}", items.len());
371+
let types: Vec<String> = items
372+
.iter()
373+
.filter_map(|item| item.get("@type").and_then(|v| v.as_str()))
374+
.map(ToString::to_string)
375+
.collect();
376+
if !types.is_empty() {
377+
println!(" Details Types: {}", types.join(", "));
378+
}
379+
}
380+
} else {
381+
println!(" Details: must be absent on backend");
382+
}
383+
}
384+
let mut option_flags = Vec::new();
385+
if section.inline_options.with_asserts {
386+
option_flags.push("with_asserts");
387+
}
388+
if !option_flags.is_empty() {
389+
println!(" Options: {}", option_flags.join(", "));
367390
}
368-
println!(" Action: Verify gRPC error status and message");
391+
println!(" Action: Verify gRPC error status, message, and details policy");
369392
step += 1;
370393
}
371394
SectionType::Extract => {

src/commands/inspect.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,4 +627,34 @@ fn print_logic_flow(doc: &parser::GctfDocument) {
627627
if partial_count > 0 {
628628
println!(" Partial Matching: {} section(s)", partial_count);
629629
}
630+
631+
let strict_error_details_count = doc
632+
.sections
633+
.iter()
634+
.filter(|s| {
635+
s.section_type == parser::ast::SectionType::Error
636+
&& matches!(s.content, parser::ast::SectionContent::Json(ref v) if v.get("details").is_none())
637+
})
638+
.count();
639+
if strict_error_details_count > 0 {
640+
println!(
641+
" Error Details Policy: strict absence for {} ERROR section(s)",
642+
strict_error_details_count
643+
);
644+
}
645+
646+
let required_error_details_count = doc
647+
.sections
648+
.iter()
649+
.filter(|s| {
650+
s.section_type == parser::ast::SectionType::Error
651+
&& matches!(s.content, parser::ast::SectionContent::Json(ref v) if v.get("details").is_some())
652+
})
653+
.count();
654+
if required_error_details_count > 0 {
655+
println!(
656+
" Error Details Policy: required for {} ERROR section(s)",
657+
required_error_details_count
658+
);
659+
}
630660
}

0 commit comments

Comments
 (0)