Skip to content

Commit 0f10982

Browse files
Updates config new to read template from tag. Closes #997 (#1001)
1 parent 8f483c0 commit 0f10982

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

dev-proxy/CommandHandlers/ConfigNewCommandHandler.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class VisualStudioCodeSnippet
1717

1818
public static class ConfigNewCommandHandler
1919
{
20-
private static readonly string snippetsFileUrl = "https://aka.ms/devproxy/snippets";
20+
private static readonly string snippetsFileUrl = $"https://aka.ms/devproxy/snippets/v{ProxyUtils.ProductVersion}";
2121
private static readonly string configFileSnippetName = "ConfigFile";
2222

2323
public static async Task CreateConfigFileAsync(string name, ILogger logger)
@@ -71,7 +71,15 @@ public static async Task CreateConfigFileAsync(string name, ILogger logger)
7171
if (response.IsSuccessStatusCode)
7272
{
7373
var content = await response.Content.ReadAsStringAsync();
74-
return JsonSerializer.Deserialize<Dictionary<string, VisualStudioCodeSnippet>>(content, ProxyUtils.JsonSerializerOptions);
74+
try
75+
{
76+
return JsonSerializer.Deserialize<Dictionary<string, VisualStudioCodeSnippet>>(content, ProxyUtils.JsonSerializerOptions);
77+
}
78+
catch (Exception ex)
79+
{
80+
logger.LogError(ex, "Failed to parse snippets from {Url}", snippetsFileUrl);
81+
return null;
82+
}
7583
}
7684
else
7785
{

0 commit comments

Comments
 (0)