Skip to content

Commit

Permalink
fix(alert-cli): file not found error via github api
Browse files Browse the repository at this point in the history
  • Loading branch information
maxgfr committed Jul 28, 2023
1 parent 6e06dce commit e7285ac
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions targets/alert-cli/src/APIs/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export class GithubApi {

async raw(project: string, path: string, tag: GitTagData): Promise<string> {
const url = `https://raw.githubusercontent.com/${project}/${tag.ref}/${path}`;
const data = await this.fetchText(url);
const data = await this.fetchText(url, true);
return data;
}

Expand All @@ -103,12 +103,19 @@ export class GithubApi {
return data as T;
}

private async fetchText(url: string): Promise<string> {
private async fetchText(url: string, ignoreError?: boolean): Promise<string> {
const response = await this.fetchGithub(url);
if (!response.ok) {
throw new Error(
`Failed to fetch ${url} - ${response.status} : ${response.statusText}`
);
if (ignoreError) {
console.error(
`Failed to fetch ${url} - ${response.status} : ${response.statusText}`
);
return "";
} else {
throw new Error(
`Failed to fetch ${url} - ${response.status} : ${response.statusText}`
);
}
}
return response.text();
}
Expand Down

0 comments on commit e7285ac

Please sign in to comment.