From 4837cd10064cd5cc91b5aea8012464e3b891ec03 Mon Sep 17 00:00:00 2001 From: Adam Reeve Date: Tue, 2 Jul 2024 20:41:07 +1200 Subject: [PATCH] Convert ParquetStatusException with OutOfMemory code to OutOfMemory exception --- cpp/ExceptionInfo.h | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/cpp/ExceptionInfo.h b/cpp/ExceptionInfo.h index 17fe194f..c013bd13 100644 --- a/cpp/ExceptionInfo.h +++ b/cpp/ExceptionInfo.h @@ -3,6 +3,8 @@ #include #include +#include + struct ExceptionInfo final { ExceptionInfo(const char* type, const char* message); @@ -14,23 +16,28 @@ struct ExceptionInfo final }; #define SINGLE_ARG(...) __VA_ARGS__ -#define TRYCATCH(expression) \ - try \ - { \ - expression \ - return nullptr; \ - } \ - catch (const std::bad_alloc& exception) \ - { \ - return new ExceptionInfo("OutOfMemoryException", exception.what()); \ - } \ - catch (const std::exception& exception) \ - { \ - return new ExceptionInfo(exception); \ - } \ - catch (...) \ - { \ - return new ExceptionInfo("unkown", "uncaught exception"); \ - } \ - +#define TRYCATCH(expression) \ + try \ + { \ + expression \ + return nullptr; \ + } \ + catch (const std::bad_alloc& exception) \ + { \ + return new ExceptionInfo("OutOfMemoryException", exception.what()); \ + } \ + catch (const parquet::ParquetStatusException& exception) \ + { \ + return exception.status().IsOutOfMemory() \ + ? new ExceptionInfo("OutOfMemoryException", exception.what()) \ + : new ExceptionInfo(exception); \ + } \ + catch (const std::exception& exception) \ + { \ + return new ExceptionInfo(exception); \ + } \ + catch (...) \ + { \ + return new ExceptionInfo("unknown", "uncaught exception"); \ + } \