From a0ca1db3790373546a9907457e87b9ec28dcedee Mon Sep 17 00:00:00 2001 From: Dennis Seah Date: Tue, 7 Apr 2020 19:27:24 -0700 Subject: [PATCH] [HOUSEKEEPING] have error identifiers for two errors in azure git lib --- src/lib/git/azure.ts | 16 ++++++++-------- src/lib/i18n.json | 2 ++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/lib/git/azure.ts b/src/lib/git/azure.ts index 8dec60d17..102b15f76 100644 --- a/src/lib/git/azure.ts +++ b/src/lib/git/azure.ts @@ -366,11 +366,10 @@ export const repositoryHasFile = async ( ); if (gitItem === null) { - throw Error( - "Error installing build pipeline. Repository does not have a " + - fileName + - " file." - ); + throw buildError(errorStatusCode.GIT_OPS_ERR, { + errorKey: "git-azure-file-no-exist-in-repo", + values: [fileName, branch, repoName], + }); } }; @@ -393,9 +392,10 @@ export const validateRepository = async ( const repo = await gitApi.getRepository(repoName, project); if (!repo) { - throw Error( - `Project '${project}' does not contain repository '${repoName}'.` - ); + throw buildError(errorStatusCode.GIT_OPS_ERR, { + errorKey: "git-azure-repo-no-exist", + values: [repoName, project], + }); } await repositoryHasFile(fileName, branch, repoName, accessOpts); diff --git a/src/lib/i18n.json b/src/lib/i18n.json index c3280caf5..52a375106 100644 --- a/src/lib/i18n.json +++ b/src/lib/i18n.json @@ -111,6 +111,8 @@ "git-azure-get-match-branch-multiple": "Got more than one matching repositories in Azure DevOps with remote url '{0}' and branches '{1}' and '{2}'.", "git-azure-get-match-branch-err": "Could not get matching branch in Azure DevOps", "git-azure-create-pull-request-err": "Could not create pull request in Azure DevOps", + "git-azure-repo-no-exist": "Repository {0} did not exist in project {1}.", + "git-azure-file-no-exist-in-repo": "File {0} did not exist in {1} branch in repository {2}.", "fileutils-append-variable-group-to-pipeline-yaml": "Could not append variable group name to manifest-generation.yaml file in HLD repo. Check this is file exist and if it is YAML format.", "fileutils-generate-hld-pipeline-yaml": "Could not generate HLD Azure pipeline YAML.",