[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: error() or nil, 'error msg'
- From: Sean Conner <sean@...>
- Date: Thu, 11 Sep 2014 15:38:23 -0400
It was thus said that the Great William Ahern once stated:
> On Thu, Sep 11, 2014 at 09:50:29AM -0400, Sean Conner wrote:
> > It was thus said that the Great Andrew Starks once stated:
> <snip>
> > > Are there interesting differences between how you think about / deal with
> > > error handling in C/C++ vs. Lua? Accepting that the mechanisms are
> > > different, do you do more "try to recover" code in C?
> >
> > I don't program in C++, so I don't use exceptions. In regard to error
> > handling, I tend to handle errors in Lua like I do in C. And I don't really
> > do "recover" code in C. [2][3]
> >
>
> What do you mean by recover? Surely you handle errors like EMFILE and ENOMEM
> without exiting the process.
How would *you* handle ENOMEM?
I wrote a big on this a few years ago:
http://boston.conman.org/2009/12/01.2
And depending upon the context, ENOMEM may be a case 3 (per the post) or
case 4. I generally just stop processing if I get ENOMEM since I usually
have no idea how to handle the situation.
Then again, I rarely encounter ENOMEM since Linux does overcommit by
default, so I'll see a SIGSEGV long before ENOMEM 8-P
> In C it helps if you use failure-free data structures as much as possible,
> which is why I never use list or tree implementations that do dynamic node
> allocation. Otherwise, you need to maintain additional state and write
> additional logic to handle partial rewinding of application state.
So what do you do in C++? Is the std::vector (however it's spelled, I'm
not a C++ programmer) failure-free? Or the other default data structures
you get in C++ (or Boost)?
-spc
- References:
- error() or nil, 'error msg', Andrew Starks
- Re: error() or nil, 'error msg', Sean Conner
- Re: error() or nil, 'error msg', Andrew Starks
- Re: error() or nil, 'error msg', Sean Conner
- Re: error() or nil, 'error msg', William Ahern