[Tarantool-patches] [PATCH 11/12] popen: clarify popen_read_timeout error message

Alexander Turenko alexander.turenko at tarantool.org
Wed Apr 15 07:21:36 MSK 2020


On Tue, Apr 14, 2020 at 02:38:20PM +0300, Alexander Turenko wrote:
> Popen backend errors should be meaningful for a user of the popen Lua
> API, because otherwise we'll need to map backend errors into Lua API
> errors. This particular failure can't appear when the function is called
> from the Lua API, but it is good to keep all error messages in one
> style.
> 
> Part of #4031
> ---
>  src/lib/core/popen.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/src/lib/core/popen.c b/src/lib/core/popen.c
> index 36cd7b07d..640dffc2b 100644
> --- a/src/lib/core/popen.c
> +++ b/src/lib/core/popen.c
> @@ -360,7 +360,7 @@ popen_write_timeout(struct popen_handle *handle, const void *buf,
>   *
>   * - IllegalParams: a parameter check fails:
>   *   - count: buffer is too big.
> - *   - flags: POPEN_FLAG_FD_STD{OUT,ERR} are set or unset both.
> + *   - flags: stdout and stdrr are both choosen or both missed
>   *   - handle: handle does not support the requested IO operation.
>   * - SocketError: an IO error occurs at read().
>   * - TimedOut: @a timeout quota is exceeded.
> @@ -379,8 +379,8 @@ popen_read_timeout(struct popen_handle *handle, void *buf,
>  	}
>  
>  	if (!(flags & (POPEN_FLAG_FD_STDOUT | POPEN_FLAG_FD_STDERR))) {
> -		diag_set(IllegalParams, "popen: POPEN_FLAG_FD_STD{OUT,ERR} are "
> -			 "unset both");
> +		diag_set(IllegalParams,
> +			 "popen: neither stdout nor stderr is choosen");
>  		return -1;
>  	}

I was inattentive: there is an error message of the same style in
popen_read_timeout(). Those functions should be changed both together.

Incremental diff:

diff --git a/src/lib/core/popen.c b/src/lib/core/popen.c
index 640dffc2b..64711d737 100644
--- a/src/lib/core/popen.c
+++ b/src/lib/core/popen.c
@@ -297,7 +297,7 @@ stdX_str(unsigned int index)
  *
  * - IllegalParams: a parameter check fails:
  *   - count: data is too big.
- *   - flags: POPEN_FLAG_FD_STDIN bit is unset.
+ *   - flags: stdin is not choosen.
  *   - handle: handle does not support the requested IO operation.
  * - SocketError: an IO error occurs at write().
  * - TimedOut: @a timeout quota is exceeded.
@@ -322,8 +322,7 @@ popen_write_timeout(struct popen_handle *handle, const void *buf,
 	}
 
 	if (!(flags & POPEN_FLAG_FD_STDIN)) {
-		diag_set(IllegalParams,
-			 "popen: POPEN_FLAG_FD_STDIN bit is unset");
+		diag_set(IllegalParams, "popen: stdin is not choosen");
 		return -1;
 	}

The new commit message:

 | popen: refine popen_{read,write}_timeout errors
 |
 | Popen backend errors should be meaningful for a user of the popen Lua
 | API, because otherwise we'll need to map backend errors into Lua API
 | errors. Those particular failures can't appear when the functions are
 | called from the Lua API, but it is good to keep all error messages in
 | one style.
 |
 | Part of #4031

Don't sure, however, that 'choosen' is the right word in this context.


More information about the Tarantool-patches mailing list