@@ -165,7 +165,16 @@ function ngDefintionToDefintion(definition: ng.Definition): Definition {
165165 }
166166}
167167
168- connection . onDefinition ( ( textDocumentPosition : TextDocumentPositionParams ) : Definition => {
168+ function logErrors < T > ( f : ( ) => T ) : T {
169+ try {
170+ return f ( ) ;
171+ } catch ( e ) {
172+ if ( e . message && e . stack ) connection . console . error ( `SERVER ERROR: ${ e . message } \n${ e . stack } ` ) ;
173+ throw e ;
174+ }
175+ }
176+
177+ connection . onDefinition ( ( textDocumentPosition : TextDocumentPositionParams ) : Definition => logErrors ( ( ) => {
169178 const { fileName, service, offset, languageId} = documents . getServiceInfo ( textDocumentPosition . textDocument ,
170179 textDocumentPosition . position )
171180 if ( fileName && service && offset != null ) {
@@ -174,7 +183,7 @@ connection.onDefinition((textDocumentPosition: TextDocumentPositionParams): Defi
174183 return ngDefintionToDefintion ( result ) ;
175184 }
176185 }
177- } ) ;
186+ } ) ) ;
178187
179188function ngHoverToHover ( hover : ng . Hover , document : TextDocumentIdentifier ) : Hover {
180189 if ( hover ) {
@@ -189,7 +198,7 @@ function ngHoverToHover(hover: ng.Hover, document: TextDocumentIdentifier): Hove
189198 }
190199}
191200
192- connection . onHover ( ( textDocumentPosition : TextDocumentPositionParams ) : Hover => {
201+ connection . onHover ( ( textDocumentPosition : TextDocumentPositionParams ) : Hover => logErrors ( ( ) => {
193202 const { fileName, service, offset, languageId} = documents . getServiceInfo ( textDocumentPosition . textDocument ,
194203 textDocumentPosition . position )
195204 if ( fileName && service && offset != null ) {
@@ -198,7 +207,7 @@ connection.onHover((textDocumentPosition: TextDocumentPositionParams): Hover =>
198207 return ngHoverToHover ( result , textDocumentPosition . textDocument ) ;
199208 }
200209 }
201- } ) ;
210+ } ) ) ;
202211
203212// Listen on the connection
204213connection . listen ( ) ;
0 commit comments