From a1da04bacec62e5a03a145d39a34d035077e97cd Mon Sep 17 00:00:00 2001 From: Leonardo Rodrigues de Mello Date: Mon, 9 Sep 2024 13:08:01 -0400 Subject: [PATCH] Fix pylint errors --- src/storage/gcp_storage.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/storage/gcp_storage.py b/src/storage/gcp_storage.py index 9cfdc19..5dffbc6 100644 --- a/src/storage/gcp_storage.py +++ b/src/storage/gcp_storage.py @@ -2,10 +2,11 @@ This module provides an implementation of the BaseStorage class for Google Cloud Storage. """ +from io import BytesIO import logging from google.cloud import storage from google.oauth2 import service_account -from io import BytesIO +from google.api_core import exceptions as gcp_exceptions import pandas as pd from .base_storage import BaseStorage @@ -72,7 +73,17 @@ def save_data(self, data: pd.core.frame.DataFrame, config) -> str | None: blob.upload_from_file( parquet_file, content_type='application/octet-stream') return blob.public_url - except Exception as e: - logger.error(e) + except gcp_exceptions.BadRequest as e: + logger.error("Bad Request Error: %s", e) + except gcp_exceptions.Forbidden as e: + logger.error("Forbidden Error: %s", e) + except gcp_exceptions.NotFound as e: + logger.error("Not Found Error: %s", e) + except gcp_exceptions.TooManyRequests as e: + logger.error("Too Many Requests Error: %s", e) + except gcp_exceptions.InternalServerError as e: + logger.error("Internal Server Error: %s", e) + except gcp_exceptions.GoogleAPIError as e: + logger.error("Google API Error: %s", e) return None