[tarantool-patches] Re: [PATCH 0/2 v2] fio: show function name in all fio errors

roman roman.habibov at tarantool.org
Sat Dec 8 16:41:08 MSK 2018


Hi! Thanks for review.
> I think within scope of this issue we should only add function names
> into error messages and add path part number, but remove the second
> parameter of the error() function where it is used across the fio
> module.

Removed.

diff --git a/src/lua/fio.lua b/src/lua/fio.lua
index 55faebdcb..2fee13e2d 100644
--- a/src/lua/fio.lua
+++ b/src/lua/fio.lua
@@ -126,7 +126,7 @@ fio_methods.seek = function(self, offset, whence)
      end
      if type(whence) == 'string' then
          if fio.c.seek[whence] == nil then
-            error(sprintf("Unknown whence: %s", whence))
+            error(sprintf("fio.seek(): unknown whence: %s", whence))
          end
          whence = fio.c.seek[whence]
      else
@@ -179,7 +179,7 @@ fio.open = function(path, flags, mode)
              iflag = bit.bor(iflag, flag)
          else
              if fio.c.flag[ flag ] == nil then
-                error(sprintf("Unknown flag: %s", flag))
+                error(sprintf("fio.open(): unknown flag: %s", flag))
              end
              iflag = bit.bor(iflag, fio.c.flag[ flag ])
          end
@@ -188,7 +188,7 @@ fio.open = function(path, flags, mode)
      for _, m in pairs(mode) do
          if type(m) == 'string' then
              if fio.c.mode[m] == nil then
-                error(sprintf("Unknown mode: %s", m))
+                error(sprintf("fio.open(): unknown mode: %s", m))
              end
              imode = bit.bor(imode, fio.c.mode[m])
          else
@@ -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("fio.pathjoin() undefined path part "..i)
          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("fio.pathjoin() undefined path part "..i)
          end

          sp = tostring(sp)
diff --git a/test/app/fio.result b/test/app/fio.result
index b7a1f65c6..38d908276 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: 'builtin/fio.lua:216: fio.pathjoin() undefined path part 1'
+...
+fio.pathjoin('abc', nil)
+---
+- error: 'builtin/fio.lua:236: fio.pathjoin() undefined path part 2'
+...
+fio.pathjoin('abc', 'cde', nil)
+---
+- error: 'builtin/fio.lua:236: fio.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




More information about the Tarantool-patches mailing list