improve error handling

This commit is contained in:
SrGooglo 2024-11-04 13:49:26 +00:00
parent f53fab016e
commit 8771c6dae7

View File

@ -57,7 +57,7 @@ export class StorageClient extends Minio.Client {
initialize = async () => { initialize = async () => {
console.log("🔌 Checking if storage client have default bucket...") console.log("🔌 Checking if storage client have default bucket...")
// check connection with s3 try {
const bucketExists = await this.bucketExists(this.defaultBucket) const bucketExists = await this.bucketExists(this.defaultBucket)
if (!bucketExists) { if (!bucketExists) {
@ -68,7 +68,11 @@ export class StorageClient extends Minio.Client {
// set default bucket policy // set default bucket policy
await this.setDefaultBucketPolicy(this.defaultBucket) await this.setDefaultBucketPolicy(this.defaultBucket)
} }
} catch (error) {
console.error(`Failed to check if default bucket exists or create default bucket >`, error)
}
try {
// check if default bucket policy exists // check if default bucket policy exists
const bucketPolicy = await this.getBucketPolicy(this.defaultBucket).catch(() => { const bucketPolicy = await this.getBucketPolicy(this.defaultBucket).catch(() => {
return null return null
@ -78,6 +82,9 @@ export class StorageClient extends Minio.Client {
// set default bucket policy // set default bucket policy
await this.setDefaultBucketPolicy(this.defaultBucket) await this.setDefaultBucketPolicy(this.defaultBucket)
} }
} catch (error) {
console.error(`Failed to get or set default bucket policy >`, error)
}
console.log("✅ Storage client is ready.") console.log("✅ Storage client is ready.")
} }