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 <ckruse@flexport.com>
This commit is contained in:
Christopher Kruse
2023-02-13 10:28:03 -08:00
parent 8cd21b9b59
commit 67ed635524
@@ -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);
}
}
}