File tree Expand file tree Collapse file tree 1 file changed +16
-10
lines changed Expand file tree Collapse file tree 1 file changed +16
-10
lines changed Original file line number Diff line number Diff line change @@ -77,17 +77,23 @@ export async function getContextItems(input: string, options: PromptOptions = {}
77
77
// If the user referenced a table, view, or other object, let's fetch related objects
78
78
progress ( `Finding objects related to ${ prettyNameRef } ...` ) ;
79
79
80
- const relatedObjects = await Schemas . getRelatedObjects ( ref ) ;
81
- const contentItems = await getContentItemsForRefs ( relatedObjects ) ;
82
-
83
- contextItems . push ( ...contentItems ) ;
84
-
85
- // Then also add some follow ups
86
- if ( relatedObjects . length === 1 ) {
87
- followUps . push ( `How is ${ prettyNameRef } related to ${ Statement . prettyName ( relatedObjects [ 0 ] . name ) } ?` ) ;
88
- } else if ( ref . sqlType === `TABLE` ) {
89
- followUps . push ( `What are some objects related to that table?` ) ;
80
+ try {
81
+ const relatedObjects = await Schemas . getRelatedObjects ( ref ) ;
82
+ const contentItems = await getContentItemsForRefs ( relatedObjects ) ;
83
+
84
+ contextItems . push ( ...contentItems ) ;
85
+
86
+ // Then also add some follow ups
87
+ if ( relatedObjects . length === 1 ) {
88
+ followUps . push ( `How is ${ prettyNameRef } related to ${ Statement . prettyName ( relatedObjects [ 0 ] . name ) } ?` ) ;
89
+ } else if ( ref . sqlType === `TABLE` ) {
90
+ followUps . push ( `What are some objects related to that table?` ) ;
91
+ }
92
+ } catch ( e ) {
93
+ followUps . push ( `What objects are in ${ Statement . prettyName ( ref . schema ) } ?` ) ;
94
+ console . log ( e ) ;
90
95
}
96
+
91
97
}
92
98
93
99
} else if ( userInput . refs . length > 1 ) {
You can’t perform that action at this time.
0 commit comments