Tarantool development patches archive
 help / color / mirror / Atom feed
* [tarantool-patches] [PATCH] lua: modify the error message in 'fio.pathjoin'
@ 2018-12-02  0:27 Roman Khabibov
  2018-12-03 14:25 ` [tarantool-patches] " Vladislav Shpilevoy
  0 siblings, 1 reply; 2+ messages in thread
From: Roman Khabibov @ 2018-12-02  0:27 UTC (permalink / raw)
  To: tarantool-patches; +Cc: v.shpilevoy

Display line number with error and fix the bug with bad argument number.

Closes #3580

Branch: https://github.com/tarantool/tarantool/tree/romanhabibov/gh-3580-err-msg-pathjoin
Issue: https://github.com/tarantool/tarantool/issues/3580
---
 src/lua/fio.lua       |  4 ++--
 test/app/fio.result   | 13 +++++++++++++
 test/app/fio.test.lua |  5 +++++
 3 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/src/lua/fio.lua b/src/lua/fio.lua
index 55faebdcb..13a4d36dc 100644
--- a/src/lua/fio.lua
+++ b/src/lua/fio.lua
@@ -213,7 +213,7 @@ fio.pathjoin = function(...)
     while i <= len do
         local sp = select(i, ...)
         if sp == nil then
-            error("Undefined path part "..i)
+            error("in function 'pathjoin' undefined path part "..i, 2)
         end
 
         sp = tostring(sp)
@@ -233,7 +233,7 @@ fio.pathjoin = function(...)
     while i <= len do
         local sp = select(i, ...)
         if sp == nil then
-            error("Undefined path part")
+            error("in function 'pathjoin' undefined path part "..i, 2)
         end
 
         sp = tostring(sp)
diff --git a/test/app/fio.result b/test/app/fio.result
index b7a1f65c6..fd3e289c4 100644
--- a/test/app/fio.result
+++ b/test/app/fio.result
@@ -55,6 +55,19 @@ fio.pathjoin('abc', 'awdeq///qweqwqwe///', "//asda//")
 ---
 - abc/awdeq/qweqwqwe/asda
 ...
+--gh-3580 Modify the error message in 'fio.pathjoin'.
+fio.pathjoin(nil)
+---
+- error: in function 'pathjoin' undefined path part 1
+...
+fio.pathjoin('abc', nil)
+---
+- error: in function 'pathjoin' undefined path part 2
+...
+fio.pathjoin('abc', 'cde', nil)
+---
+- error: in function 'pathjoin' undefined path part 3
+...
 -- basename
 st, err = pcall(fio.basename, nil)
 ---
diff --git a/test/app/fio.test.lua b/test/app/fio.test.lua
index 4f34fd11c..b6c79648c 100644
--- a/test/app/fio.test.lua
+++ b/test/app/fio.test.lua
@@ -18,6 +18,11 @@ fio.pathjoin('/', '/cde')
 fio.pathjoin('/a', '/')
 fio.pathjoin('abc', 'awdeq///qweqwqwe///', "//asda//")
 
+--gh-3580 Modify the error message in 'fio.pathjoin'.
+fio.pathjoin(nil)
+fio.pathjoin('abc', nil)
+fio.pathjoin('abc', 'cde', nil)
+
 -- basename
 st, err = pcall(fio.basename, nil)
 st
-- 
2.19.1

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [tarantool-patches] Re: [PATCH] lua: modify the error message in 'fio.pathjoin'
  2018-12-02  0:27 [tarantool-patches] [PATCH] lua: modify the error message in 'fio.pathjoin' Roman Khabibov
@ 2018-12-03 14:25 ` Vladislav Shpilevoy
  0 siblings, 0 replies; 2+ messages in thread
From: Vladislav Shpilevoy @ 2018-12-03 14:25 UTC (permalink / raw)
  To: Roman Khabibov, tarantool-patches

Thanks for the patch! See 2 comments below,
review fix at the end of the email and on the
branch.

On 02/12/2018 03:27, Roman Khabibov wrote:
> Display line number with error and fix the bug with bad argument number.
> 
> Closes #3580
> 
> Branch: https://github.com/tarantool/tarantool/tree/romanhabibov/gh-3580-err-msg-pathjoin
> Issue: https://github.com/tarantool/tarantool/issues/3580
> ---
>   src/lua/fio.lua       |  4 ++--
>   test/app/fio.result   | 13 +++++++++++++
>   test/app/fio.test.lua |  5 +++++
>   3 files changed, 20 insertions(+), 2 deletions(-)
> 
> diff --git a/src/lua/fio.lua b/src/lua/fio.lua
> index 55faebdcb..13a4d36dc 100644
> --- a/src/lua/fio.lua
> +++ b/src/lua/fio.lua
> @@ -213,7 +213,7 @@ fio.pathjoin = function(...)
>       while i <= len do
>           local sp = select(i, ...)
>           if sp == nil then
> -            error("Undefined path part "..i)
> +            error("in function 'pathjoin' undefined path part "..i, 2)

1. Usually we write error messages without saying 'in function'. Also,
you did not specify module name 'fio'. I've fixed it on the branch in a
separate commit. Please, look and squash if it is ok for you.

>           end
>   
>           sp = tostring(sp)

2. The module 'fio' contains some other error messages without
function name. I've fixed them too in a follow-up commit. Look
at it, say if do not agree, but do not squash. It should be
separate.

If all my changes are ok, then send v2 patch to Vova, please.

===================================================================

commit 4ec3b8238faa0515cb13dea43a3fcc38e7ecce18
Author: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
Date:   Mon Dec 3 17:04:52 2018 +0300

     Review fix

diff --git a/src/lua/fio.lua b/src/lua/fio.lua
index 13a4d36dc..1d0bb4bd1 100644
--- a/src/lua/fio.lua
+++ b/src/lua/fio.lua
@@ -213,7 +213,7 @@ fio.pathjoin = function(...)
      while i <= len do
          local sp = select(i, ...)
          if sp == nil then
-            error("in function 'pathjoin' undefined path part "..i, 2)
+            error("fio.pathjoin() undefined path part "..i, 2)
          end
  
          sp = tostring(sp)
@@ -233,7 +233,7 @@ fio.pathjoin = function(...)
      while i <= len do
          local sp = select(i, ...)
          if sp == nil then
-            error("in function 'pathjoin' undefined path part "..i, 2)
+            error("fio.pathjoin() undefined path part "..i, 2)
          end
  
          sp = tostring(sp)
diff --git a/test/app/fio.result b/test/app/fio.result
index fd3e289c4..9777a0aec 100644
--- a/test/app/fio.result
+++ b/test/app/fio.result
@@ -58,15 +58,15 @@ fio.pathjoin('abc', 'awdeq///qweqwqwe///', "//asda//")
  --gh-3580 Modify the error message in 'fio.pathjoin'.
  fio.pathjoin(nil)
  ---
-- error: in function 'pathjoin' undefined path part 1
+- error: fio.pathjoin() undefined path part 1
  ...
  fio.pathjoin('abc', nil)
  ---
-- error: in function 'pathjoin' undefined path part 2
+- error: fio.pathjoin() undefined path part 2
  ...
  fio.pathjoin('abc', 'cde', nil)
  ---
-- error: in function 'pathjoin' undefined path part 3
+- error: fio.pathjoin() undefined path part 3
  ...
  -- basename
  st, err = pcall(fio.basename, nil)

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-12-03 14:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-02  0:27 [tarantool-patches] [PATCH] lua: modify the error message in 'fio.pathjoin' Roman Khabibov
2018-12-03 14:25 ` [tarantool-patches] " Vladislav Shpilevoy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox