2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
22 #include <arrow/api.h>
24 #include <arrow-glib/error.h>
26 gboolean garrow_error_check(GError **error,
27 const arrow::Status &status,
29 GArrowError garrow_error_from_status(const arrow::Status &status);
31 garrow_error_to_status_code(GError *error,
32 arrow::StatusCode default_code);
33 arrow::Status garrow_error_to_status(GError *error,
34 arrow::StatusCode default_code,
38 gboolean check(GError **error,
39 const arrow::Status &status,
42 template <typename CONTEXT_FUNC>
43 gboolean check(GError **error,
44 const arrow::Status &status,
45 CONTEXT_FUNC &&context_func) {
49 std::string context = std::move(context_func());
52 garrow_error_from_status(status),
55 status.ToString().c_str());
60 template <typename TYPE>
61 gboolean check(GError **error,
62 const arrow::Result<TYPE> &result,
63 const char *context) {
64 return check(error, result.status(), context);
67 template <typename TYPE, typename CONTEXT_FUNC>
68 gboolean check(GError **error,
69 const arrow::Result<TYPE> &result,
70 CONTEXT_FUNC &&context_func) {
71 return check(error, result.status(), context_func);