[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: error() or nil, 'error msg'
- From: Dirk Laurie <dirk.laurie@...>
- Date: Fri, 19 Sep 2014 21:56:40 +0200
2014-09-19 21:39 GMT+02:00 Andrew Starks <andrew.starks@trms.com>:
> How do you deal with the following:
>
> 1: You parse the input that you receive and you know it to be well-formed.
> 2: You call a library function that will look for a resource by that name
> and, if it fails, returns `nil, error`.
> 3: That same call may also generate an error. For example, perhaps the
> object contains a dependent resource that is in an invalid state.
>
> I can guess at what the answer to this question is: "if you return nil,
> error_msg, always return nil, error_msg" So, then the onus is on me to call
> pcall if there is any risk that an error would result.
>
> Is that correct?
The way I read Hisham's post, the module should return
nil, error_msg if your input was according to specs but
the operation could not be performed, but it is allowed to
error() if the fault is yours.
- References:
- error() or nil, 'error msg', Andrew Starks
- Re: error() or nil, 'error msg', Rena
- Re: error() or nil, 'error msg', Dirk Laurie
- Re: error() or nil, 'error msg', Andrew Starks
- Re: error() or nil, 'error msg', Jorge
- Re: error() or nil, 'error msg', Hisham
- Re: error() or nil, 'error msg', Andrew Starks