From c642531e2f2e1d3591057faa4bd825095f51d421 Mon Sep 17 00:00:00 2001 From: Minglei Jin Date: Thu, 24 Oct 2024 15:58:39 +0800 Subject: [PATCH 1/2] fix(az/stream): catch all exceptions from cpp --- source/libs/azure/src/az.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/source/libs/azure/src/az.cpp b/source/libs/azure/src/az.cpp index 831694356a..5989a7c333 100644 --- a/source/libs/azure/src/az.cpp +++ b/source/libs/azure/src/az.cpp @@ -416,7 +416,7 @@ _exit: return 0; } -int32_t azGetObjectToFile(const char *object_name, const char *fileName) { +int32_t azGetObjectToFileImpl(const char *object_name, const char *fileName) { int32_t code = TSDB_CODE_SUCCESS; std::string accountName = tsS3AccessKeyId[0]; std::string accountKey = tsS3AccessKeySecret[0]; @@ -450,6 +450,23 @@ int32_t azGetObjectToFile(const char *object_name, const char *fileName) { TAOS_RETURN(code); } +int32_t azGetObjectToFile(const char *object_name, const char *fileName) { + int32_t code = 0; + + try { + code = azGetObjectToFileImpl(object_name, fileName); + } catch (const std::exception &e) { + azError("%s: Reason Phrase: %s", __func__, e.what()); + + code = TAOS_SYSTEM_ERROR(EIO); + azError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code)); + + TAOS_RETURN(code); + } + + TAOS_RETURN(code); +} + int32_t azGetObjectsByPrefix(const char *prefix, const char *path) { const std::string delimiter = "/"; std::string accountName = tsS3AccessKeyId[0]; From 68f651a92f8caa674ee7c33fc35ceebf0ae6122c Mon Sep 17 00:00:00 2001 From: Minglei Jin Date: Fri, 25 Oct 2024 08:37:20 +0800 Subject: [PATCH 2/2] az/object to file: static impl func --- source/libs/azure/src/az.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/libs/azure/src/az.cpp b/source/libs/azure/src/az.cpp index 5989a7c333..5f95624c94 100644 --- a/source/libs/azure/src/az.cpp +++ b/source/libs/azure/src/az.cpp @@ -416,7 +416,7 @@ _exit: return 0; } -int32_t azGetObjectToFileImpl(const char *object_name, const char *fileName) { +static int32_t azGetObjectToFileImpl(const char *object_name, const char *fileName) { int32_t code = TSDB_CODE_SUCCESS; std::string accountName = tsS3AccessKeyId[0]; std::string accountKey = tsS3AccessKeySecret[0];