Skip to content

Commit 8098376

Browse files
authored
Fix range error when creating new function app (#481)
1 parent b56a2b0 commit 8098376

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

src/templates/DotnetTemplateRetriever.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import * as fse from 'fs-extra';
77
import { ProjectRuntime } from '../constants';
88
import { ext } from '../extensionVariables';
9+
import { localize } from '../localize';
910
import { dotnetUtils } from '../utils/dotnetUtils';
1011
import { downloadFile } from '../utils/fs';
1112
import { cliFeedJsonResponse } from '../utils/getCliFeedJson';
@@ -80,7 +81,7 @@ export function getDotnetVerifiedTemplateIds(runtime: string): string[] {
8081
case ProjectRuntime.beta:
8182
return `${id}.2.x`;
8283
default:
83-
throw new RangeError();
84+
throw new RangeError(localize('invalidRuntime', 'Invalid runtime "{0}".', runtime));
8485
}
8586
});
8687
}

src/tree/FunctionAppProvider.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,22 +68,22 @@ export class FunctionAppProvider implements IChildProvider {
6868

6969
async function getDefaultRuntime(actionContext: IActionContext): Promise<ProjectRuntime> {
7070
// Try to get VS Code setting for runtime (aka if they have a project open)
71-
let runtime: ProjectRuntime | undefined = getFuncExtensionSetting(projectRuntimeSetting);
71+
let runtime: string | undefined = getFuncExtensionSetting(projectRuntimeSetting);
7272
actionContext.properties.runtimeSource = 'VSCodeSetting';
7373

74-
if (runtime === undefined) {
74+
if (!runtime) {
7575
// Try to get the runtime that matches their local func cli version
7676
runtime = await tryGetLocalRuntimeVersion();
7777
actionContext.properties.runtimeSource = 'LocalFuncCli';
7878
}
7979

80-
if (runtime === undefined) {
80+
if (!runtime) {
8181
// Default to v1 if all else fails
8282
runtime = ProjectRuntime.one;
8383
actionContext.properties.runtimeSource = 'Backup';
8484
}
8585

8686
actionContext.properties.projectRuntime = runtime;
8787

88-
return runtime;
88+
return <ProjectRuntime>runtime;
8989
}

src/utils/getCliFeedJson.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import request = require('request-promise');
88
import { callWithTelemetryAndErrorHandling, IActionContext } from 'vscode-azureextensionui';
99
import { ProjectRuntime } from '../constants';
10+
import { localize } from '../localize';
1011

1112
const funcCliFeedUrl: string = 'https://aka.ms/V00v5v';
1213
const v1DefaultNodeVersion: string = '6.5.0';
@@ -51,7 +52,7 @@ export function getFeedRuntime(runtime: ProjectRuntime): string {
5152
case ProjectRuntime.one:
5253
return 'v1';
5354
default:
54-
throw new RangeError();
55+
throw new RangeError(localize('invalidRuntime', 'Invalid runtime "{0}".', runtime));
5556
}
5657
}
5758

0 commit comments

Comments
 (0)