Skip to content

Commit

Permalink
throw on errors (#7526)
Browse files Browse the repository at this point in the history
  • Loading branch information
catalinaperalta authored Jan 23, 2024
1 parent 7226bac commit 9868d72
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tools/tsp-client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ async function sdkInit(
const configYaml = parseYaml(tspConfig);
const serviceDir = configYaml?.parameters?.["service-dir"]?.default;
if (!serviceDir) {
Logger.error(`Parameter service-dir is not defined correctly in tspconfig.yaml. Please refer to https://github.com/Azure/azure-rest-api-specs/blob/main/specification/contosowidgetmanager/Contoso.WidgetManager/tspconfig.yaml for the right schema.`)
throw new Error(`Parameter service-dir is not defined correctly in tspconfig.yaml. Please refer to https://github.com/Azure/azure-rest-api-specs/blob/main/specification/contosowidgetmanager/Contoso.WidgetManager/tspconfig.yaml for the right schema.`)
}
Logger.debug(`Service directory: ${serviceDir}`)
const packageDir: string | undefined = configYaml?.options?.[emitter]?.["package-dir"];
if (!packageDir) {
Logger.error(`Missing package-dir in ${emitter} options of tspconfig.yaml. Please refer to https://github.com/Azure/azure-rest-api-specs/blob/main/specification/contosowidgetmanager/Contoso.WidgetManager/tspconfig.yaml for the right schema.`);
throw new Error(`Missing package-dir in ${emitter} options of tspconfig.yaml. Please refer to https://github.com/Azure/azure-rest-api-specs/blob/main/specification/contosowidgetmanager/Contoso.WidgetManager/tspconfig.yaml for the right schema.`);
}
const newPackageDir = joinPaths(outputDir, serviceDir, packageDir!)
await mkdir(newPackageDir, { recursive: true });
Expand All @@ -56,7 +56,7 @@ async function sdkInit(
const configYaml = parseYaml(data);
const serviceDir = configYaml?.parameters?.["service-dir"]?.default;
if (!serviceDir) {
Logger.error(`Parameter service-dir is not defined correctly in tspconfig.yaml. Please refer to https://github.com/Azure/azure-rest-api-specs/blob/main/specification/contosowidgetmanager/Contoso.WidgetManager/tspconfig.yaml for the right schema.`)
throw new Error(`Parameter service-dir is not defined correctly in tspconfig.yaml. Please refer to https://github.com/Azure/azure-rest-api-specs/blob/main/specification/contosowidgetmanager/Contoso.WidgetManager/tspconfig.yaml for the right schema.`)
}
Logger.debug(`Service directory: ${serviceDir}`)
const additionalDirOutput = formatAdditionalDirectories(configYaml?.parameters?.dependencies?.additionalDirectories);
Expand Down Expand Up @@ -234,7 +234,7 @@ async function main() {
await generate({ rootUrl, noCleanup: options.noCleanup, additionalEmitterOptions: options.emitterOptions});
break;
default:
Logger.error(`Unknown command: ${options.command}`);
throw new Error(`Unknown command: ${options.command}`);
}
}

Expand Down

0 comments on commit 9868d72

Please sign in to comment.