From e3aa261756f2b67657e6065d165e46f0ba2257ec Mon Sep 17 00:00:00 2001 From: "Uwe L. Korn" Date: Sun, 1 May 2016 19:06:47 +0200 Subject: [PATCH] Add macro to convert ParquetException to Status --- cpp/src/arrow/parquet/schema.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cpp/src/arrow/parquet/schema.cc b/cpp/src/arrow/parquet/schema.cc index db0d8b8c924ae..214c764f08b6e 100644 --- a/cpp/src/arrow/parquet/schema.cc +++ b/cpp/src/arrow/parquet/schema.cc @@ -21,11 +21,13 @@ #include #include "parquet/api/schema.h" +#include "parquet/exception.h" #include "arrow/types/decimal.h" #include "arrow/types/string.h" #include "arrow/util/status.h" +using parquet::ParquetException; using parquet::Repetition; using parquet::schema::Node; using parquet::schema::NodePtr; @@ -39,6 +41,11 @@ namespace arrow { namespace parquet { +#define PARQUET_CATCH_NOT_OK(s) \ + try { \ + (s); \ + } catch (const ParquetException& e) { return Status::Invalid(e.what()); } + const auto BOOL = std::make_shared(); const auto UINT8 = std::make_shared(); const auto INT32 = std::make_shared(); @@ -300,7 +307,7 @@ Status ToParquetSchema( NodePtr schema = GroupNode::Make("schema", Repetition::REPEATED, nodes); *out = std::make_shared<::parquet::SchemaDescriptor>(); - (*out)->Init(schema); + PARQUET_CATCH_NOT_OK((*out)->Init(schema)); return Status::OK(); }