Repository: apache/arrow
File: cpp/src/parquet/exception.h (C/C++)

Code before:
// regarding copyright ownership.  The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License.  You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.  See the License for the
// specific language governing permissions and limitations
// under the License.

#pragma once

#include <exception>
#include <sstream>
#include <string>
#include <utility>

#include "arrow/type_fwd.h"
#include "arrow/util/string_util.h"
#include "parquet/platform.h"

// PARQUET-1085
#if !defined(ARROW_UNUSED)
#  define ARROW_UNUSED(x) UNUSED(x)
#endif

// Parquet exception to Arrow Status

#define BEGIN_PARQUET_CATCH_EXCEPTIONS try {
#define END_PARQUET_CATCH_EXCEPTIONS                   \
  }                                                    \
  catch (const ::parquet::ParquetStatusException& e) { \
    return e.status();                                 \
  }                                                    \
  catch (const ::parquet::ParquetException& e) {       \
    return ::arrow::Status::IOError(e.what());         \
  }

// clang-format off

#define PARQUET_CATCH_NOT_OK(s)    \
  BEGIN_PARQUET_CATCH_EXCEPTIONS   \
  (s);                             \
  END_PARQUET_CATCH_EXCEPTIONS

// clang-format on


Review comment (refactor):
Can we remove this? It seems that `#ifdef _MSC_VER` is enough.

```suggestion
```

Code after:
// regarding copyright ownership.  The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License.  You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.  See the License for the
// specific language governing permissions and limitations
// under the License.

#pragma once

#include <exception>
#include <sstream>
#include <string>
#include <utility>

#include "arrow/type_fwd.h"
#include "arrow/util/string_util.h"
#include "parquet/platform.h"

#ifdef _MSC_VER
#  pragma warning(push)
// Disable warning for STL types usage in DLL interface
// https://web.archive.org/web/20130317015847/http://connect.microsoft.com/VisualStudio/feedback/details/696593/vc-10-vs-2010-basic-string-exports
#  pragma warning(disable : 4275 4251)
// Disable diamond inheritance warnings
#  pragma warning(disable : 4250)
// Disable macro redefinition warnings
#  pragma warning(disable : 4005)
// Disable extern before exported template warnings
#  pragma warning(disable : 4910)
#endif

// PARQUET-1085
#if !defined(ARROW_UNUSED)
#  define ARROW_UNUSED(x) UNUSED(x)
#endif

// Parquet exception to Arrow Status

#define BEGIN_PARQUET_CATCH_EXCEPTIONS try {
#define END_PARQUET_CATCH_EXCEPTIONS                   \
  }                                                    \
  catch (const ::parquet::ParquetStatusException& e) { \
    return e.status();                                 \
  }                                                    \