Skip to content

Commit

Permalink
Convert ParquetStatusException with OutOfMemory code to OutOfMemory e…
Browse files Browse the repository at this point in the history
…xception
  • Loading branch information
adamreeve committed Jul 2, 2024
1 parent 7a83fdc commit 4837cd1
Showing 1 changed file with 26 additions and 19 deletions.
45 changes: 26 additions & 19 deletions cpp/ExceptionInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include <exception>
#include <string>

#include <parquet/exception.h>

struct ExceptionInfo final
{
ExceptionInfo(const char* type, const char* message);
Expand All @@ -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"); \
} \

0 comments on commit 4837cd1

Please sign in to comment.