From 67ed63552446b512d549e911e13cd7d36eb36186 Mon Sep 17 00:00:00 2001 From: Christopher Kruse Date: Mon, 13 Feb 2023 10:28:03 -0800 Subject: [PATCH] fix: use `NotFoundError` for missing team in org Per [PR comment][1], better to use the provided error type that more closely matches the error encountered. [1]: https://github.com/backstage/backstage/pull/16059#discussion_r1103873709 Signed-off-by: Christopher Kruse --- .../src/scaffolder/actions/builtin/github/helpers.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/github/helpers.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/github/helpers.ts index dc8c4cd856..75c8f25d8b 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/github/helpers.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/github/helpers.ts @@ -15,7 +15,7 @@ */ import { Config } from '@backstage/config'; -import { assertError, InputError } from '@backstage/errors'; +import { assertError, InputError, NotFoundError } from '@backstage/errors'; import { DefaultGithubCredentialsProvider, GithubCredentialsProvider, @@ -370,7 +370,7 @@ async function validateAccessTeam(client: Octokit, access: string) { if (e.response.data.message === 'Not Found') { const message = `Received 'Not Found' from the API; one of org: ${org} or team: ${team_slug} was not found within GitHub.`; - throw new Error(message, { cause: e }); + throw new NotFoundError(message); } } }