Skip to content

Commit 638dc93

Browse files
committed
Shared: Nicer panic message if node kind is missing
Still panics, just with a better message
1 parent b027ac3 commit 638dc93

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

  • shared/tree-sitter-extractor/src/extractor

shared/tree-sitter-extractor/src/extractor/mod.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -479,13 +479,14 @@ impl<'a> Visitor<'a> {
479479
let (id, _, child_nodes) = self.stack.pop().expect("Vistor: empty stack");
480480
let loc = location_for(self, self.file_label, node);
481481
let loc_label = location_label(self.trap_writer, loc);
482+
let type_name = TypeName {
483+
kind: node.kind().to_owned(),
484+
named: node.is_named(),
485+
};
482486
let table = self
483487
.schema
484-
.get(&TypeName {
485-
kind: node.kind().to_owned(),
486-
named: node.is_named(),
487-
})
488-
.unwrap();
488+
.get(&type_name)
489+
.unwrap_or_else(|| panic!("missing extractor schema entry for {:?}", type_name));
489490
let mut valid = true;
490491
let parent_info = match self.stack.last_mut() {
491492
Some(p) if !node.is_extra() => {

0 commit comments

Comments
 (0)