@@ -640,12 +640,12 @@ export function createHierarchyRequestHandler<P extends TypeHierarchySupertypesP
640640 if ( cancellationError ) {
641641 return cancellationError ;
642642 }
643- const language = serviceRegistry . getServices ( uri ) ;
644- if ( ! language ) {
645- const message = `Could not find service instance for uri: '${ uri . toString ( ) } '` ;
646- console . error ( message ) ;
647- throw new Error ( message ) ;
643+ if ( ! serviceRegistry . hasServices ( uri ) ) {
644+ const errorText = `Could not find service instance for uri: '${ uri } '` ;
645+ console . debug ( errorText ) ;
646+ return responseError < E > ( new Error ( errorText ) ) ;
648647 }
648+ const language = serviceRegistry . getServices ( uri ) ;
649649 try {
650650 return await serviceCall ( language , params , cancelToken ) ;
651651 } catch ( err ) {
@@ -667,14 +667,14 @@ export function createServerRequestHandler<P extends { textDocument: TextDocumen
667667 if ( cancellationError ) {
668668 return cancellationError ;
669669 }
670- const language = serviceRegistry . getServices ( uri ) ;
671- if ( ! language ) {
670+ if ( ! serviceRegistry . hasServices ( uri ) ) {
672671 const errorText = `Could not find service instance for uri: '${ uri } '` ;
673- console . error ( errorText ) ;
674- throw new Error ( errorText ) ;
672+ console . debug ( errorText ) ;
673+ return responseError < E > ( new Error ( errorText ) ) ;
675674 }
676- const document = await documents . getOrCreateDocument ( uri ) ;
675+ const language = serviceRegistry . getServices ( uri ) ;
677676 try {
677+ const document = await documents . getOrCreateDocument ( uri ) ;
678678 return await serviceCall ( language , document , params , cancelToken ) ;
679679 } catch ( err ) {
680680 return responseError < E > ( err ) ;
@@ -695,16 +695,13 @@ export function createRequestHandler<P extends { textDocument: TextDocumentIdent
695695 if ( cancellationError ) {
696696 return cancellationError ;
697697 }
698- const language = serviceRegistry . getServices ( uri ) ;
699- if ( ! language ) {
700- console . error ( `Could not find service instance for uri: '${ uri . toString ( ) } '` ) ;
701- return null ;
702- }
703- const document = documents . getDocument ( uri ) ;
704- if ( ! document ) {
698+ if ( ! serviceRegistry . hasServices ( uri ) ) {
699+ console . debug ( `Could not find service instance for uri: '${ uri . toString ( ) } '` ) ;
705700 return null ;
706701 }
702+ const language = serviceRegistry . getServices ( uri ) ;
707703 try {
704+ const document = await documents . getOrCreateDocument ( uri ) ;
708705 return await serviceCall ( language , document , params , cancelToken ) ;
709706 } catch ( err ) {
710707 return responseError < E > ( err ) ;
0 commit comments