File tree 1 file changed +15
-2
lines changed
1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -191,8 +191,21 @@ impl<'a, T: 'a + Clone> Plugin<T> {
191
191
name : & str ,
192
192
params : serde_json:: Value ,
193
193
) -> Result < serde_json:: Value , PluginError > {
194
- let command = self . rpc_method . get ( name) . unwrap ( ) . clone ( ) ;
195
- command. call ( self , params)
194
+ let Some ( command) = self . rpc_method . get ( name) else {
195
+ return self . call_hook ( name, params) ;
196
+ } ;
197
+ command. clone ( ) . call ( self , params)
198
+ }
199
+
200
+ fn call_hook (
201
+ & mut self ,
202
+ name : & str ,
203
+ params : serde_json:: Value ,
204
+ ) -> Result < serde_json:: Value , PluginError > {
205
+ let Some ( command) = self . rpc_hook . get ( name) else {
206
+ return Err ( crate :: error!( "callback for method/hook `{name}` not found" ) ) ;
207
+ } ;
208
+ command. clone ( ) . call ( self , params)
196
209
}
197
210
198
211
fn handle_notification ( & ' a mut self , name : & str , params : serde_json:: Value ) {
You can’t perform that action at this time.
0 commit comments