File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
src/Features/LanguageServer/Protocol/Extensions Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -170,10 +170,23 @@ public static string GetDocumentFilePathFromUri(Uri uri)
170170 /// For example, UNC paths with invalid characters in server name.
171171 /// </exception>
172172 public static Uri CreateAbsoluteUri ( string absolutePath )
173+ {
174+ var uriString = IsAscii ( absolutePath ) ? absolutePath : GetAbsoluteUriString ( absolutePath ) ;
175+ try
176+ {
173177#pragma warning disable RS0030 // Do not use banned APIs
174- => new ( IsAscii ( absolutePath ) ? absolutePath : GetAbsoluteUriString ( absolutePath ) , UriKind . Absolute ) ;
178+ return new ( uriString , UriKind . Absolute ) ;
175179#pragma warning restore
176180
181+ }
182+ catch ( UriFormatException e )
183+ {
184+ // The standard URI format exception does not include the failing path, however
185+ // in pretty much all cases we need to know the URI string (and original string) in order to fix the issue.
186+ throw new UriFormatException ( $ "Failed create URI from '{ uriString } '; original string: '{ absolutePath } '", e ) ;
187+ }
188+ }
189+
177190 // Implements workaround for https://github.com/dotnet/runtime/issues/89538:
178191 internal static string GetAbsoluteUriString ( string absolutePath )
179192 {
You can’t perform that action at this time.
0 commit comments