@@ -177,9 +177,15 @@ define(function (require, exports, module) {
177177
178178 // Redispatch these CodeMirror key events as Editor events
179179 function _onKeyEvent ( instance , event ) {
180- if ( _keyEventInterceptor && _keyEventInterceptor ( self , self . _codeMirror , event ) ) {
181- // the interceptor processed it, so don't pass it along to CodeMirror'
182- return ;
180+ if ( _keyEventInterceptor ) {
181+ try {
182+ if ( _keyEventInterceptor ( self , self . _codeMirror , event ) ) {
183+ // the interceptor processed it, so don't pass it along to CodeMirror'
184+ return ;
185+ }
186+ } catch ( e ) {
187+ logger . reportError ( e , "Error in key event interceptor" ) ;
188+ }
183189 }
184190 self . trigger ( "keyEvent" , self , event ) ; // deprecated
185191 self . trigger ( event . type , self , event ) ;
@@ -256,23 +262,35 @@ define(function (require, exports, module) {
256262 self . _codeMirror . on ( "cut" , function ( cm , e ) {
257263 // Let interceptor decide what to do with the event (including preventDefault)
258264 if ( _cutInterceptor ) {
259- return _cutInterceptor ( self , cm , e ) ;
265+ try {
266+ return _cutInterceptor ( self , cm , e ) ;
267+ } catch ( e ) {
268+ logger . reportError ( e , "Error in cut interceptor" ) ;
269+ }
260270 }
261271 // Otherwise allow normal cut behavior
262272 } ) ;
263273
264274 self . _codeMirror . on ( "copy" , function ( cm , e ) {
265275 // Let interceptor decide what to do with the event (including preventDefault)
266276 if ( _copyInterceptor ) {
267- return _copyInterceptor ( self , cm , e ) ;
277+ try {
278+ return _copyInterceptor ( self , cm , e ) ;
279+ } catch ( e ) {
280+ logger . reportError ( e , "Error in copy interceptor" ) ;
281+ }
268282 }
269283 // Otherwise allow normal copy behavior
270284 } ) ;
271285
272286 self . _codeMirror . on ( "paste" , function ( cm , e ) {
273287 // Let interceptor decide what to do with the event (including preventDefault)
274288 if ( _pasteInterceptor ) {
275- return _pasteInterceptor ( self , cm , e ) ;
289+ try {
290+ return _pasteInterceptor ( self , cm , e ) ;
291+ } catch ( e ) {
292+ logger . reportError ( e , "Error in paste interceptor" ) ;
293+ }
276294 }
277295 // Otherwise allow normal paste behavior
278296 } ) ;
0 commit comments