Skip to content

Commit

Permalink
feat: improve error on missing build
Browse files Browse the repository at this point in the history
  • Loading branch information
rams23 committed Oct 17, 2023
1 parent 8cae6dd commit d4dc268
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
9 changes: 6 additions & 3 deletions packages/storage-gcp/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ class GCPStorage extends RemoteStorage {
"utf8"
);
const credentials = JSON.parse(jsonFileContent.toString());
console.log("credentials", credentials)
console.log("options", options);
const storage = new Storage({
credentials
})
Expand Down Expand Up @@ -107,7 +105,12 @@ class GCPStorage extends RemoteStorage {

async getBuildInfo(buildId: string): Promise<ProjectBuildInfo> {
const buildpath = this.getBuildPath(buildId);
const fileContent = await this.downloadFileFromGcp(`${buildpath}/info.json`);
let fileContent: string = "";
try {
fileContent = (await this.downloadFileFromGcp(`${buildpath}/info.json`)).toString();
}catch (e) {
throw new Error(`Build ${buildId} not found`);
}
return JSON.parse(fileContent.toString());
}

Expand Down
7 changes: 6 additions & 1 deletion packages/storage-s3/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,12 @@ class S3Storage extends RemoteStorage {

async getBuildInfo(buildId: string): Promise<ProjectBuildInfo> {
const buildpath = this.getBuildPath(buildId);
const fileContent = await this.downloadFileFromS3(`${buildpath}/info.json`);
let fileContent: string = "";
try {
fileContent = (await this.downloadFileFromS3(`${buildpath}/info.json`)).toString();
}catch (e) {
throw new Error(`Build ${buildId} not found`);
}
return JSON.parse(fileContent.toString());
}

Expand Down

0 comments on commit d4dc268

Please sign in to comment.