You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@arrow.apache.org by Li Jin <ic...@gmail.com> on 2023/06/29 14:20:39 UTC
[C++] Dealing with third party method that raises exception
Hi,
IIUC, most of the Arrow C++ code doesn't not use exceptions. My question is
are there some Arrow utility / macro that wrap the function/code that might
raise an exception and turn that into code that returns an arrow error
Status?
Thanks!
Li
Re: [C++] Dealing with third party method that raises exception
Posted by Weston Pace <we...@gmail.com>.
We do this quite a bit in the Arrow<->Parquet bridge if IIUC. There are
macros defined like this:
```
#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()); \
}
```
That being said, I'm not particularly fond of macros, but it works.
On Thu, Jun 29, 2023 at 8:09 AM Li Jin <ic...@gmail.com> wrote:
> Thanks Antoine - the examples are useful - I can use the same pattern for
> now. Thanks for the quick response!
>
> On Thu, Jun 29, 2023 at 10:47 AM Antoine Pitrou <an...@python.org>
> wrote:
>
> >
> > Hi Li,
> >
> > There is not currently, but it would probably be a useful small utility.
> > If you look for `std::exception` in the codebase, you'll find that there
> > a couple of places where we turn it into a Status already.
> >
> > Regards
> >
> > Antoine.
> >
> >
> > Le 29/06/2023 à 16:20, Li Jin a écrit :
> > > Hi,
> > >
> > > IIUC, most of the Arrow C++ code doesn't not use exceptions. My
> question
> > is
> > > are there some Arrow utility / macro that wrap the function/code that
> > might
> > > raise an exception and turn that into code that returns an arrow error
> > > Status?
> > >
> > > Thanks!
> > > Li
> > >
> >
>
Re: [C++] Dealing with third party method that raises exception
Posted by Li Jin <ic...@gmail.com>.
Thanks Antoine - the examples are useful - I can use the same pattern for
now. Thanks for the quick response!
On Thu, Jun 29, 2023 at 10:47 AM Antoine Pitrou <an...@python.org> wrote:
>
> Hi Li,
>
> There is not currently, but it would probably be a useful small utility.
> If you look for `std::exception` in the codebase, you'll find that there
> a couple of places where we turn it into a Status already.
>
> Regards
>
> Antoine.
>
>
> Le 29/06/2023 à 16:20, Li Jin a écrit :
> > Hi,
> >
> > IIUC, most of the Arrow C++ code doesn't not use exceptions. My question
> is
> > are there some Arrow utility / macro that wrap the function/code that
> might
> > raise an exception and turn that into code that returns an arrow error
> > Status?
> >
> > Thanks!
> > Li
> >
>
Re: [C++] Dealing with third party method that raises exception
Posted by Antoine Pitrou <an...@python.org>.
Hi Li,
There is not currently, but it would probably be a useful small utility.
If you look for `std::exception` in the codebase, you'll find that there
a couple of places where we turn it into a Status already.
Regards
Antoine.
Le 29/06/2023 à 16:20, Li Jin a écrit :
> Hi,
>
> IIUC, most of the Arrow C++ code doesn't not use exceptions. My question is
> are there some Arrow utility / macro that wrap the function/code that might
> raise an exception and turn that into code that returns an arrow error
> Status?
>
> Thanks!
> Li
>