[tarantool-patches] [PATCH] tarantoolctl: update confusing error message

Konstantin Belyavskiy k.belyavskiy at tarantool.org
Thu Aug 9 17:18:06 MSK 2018


There were two complains regarding to tarantoolctl eval behaviour:
1. confusing message - fixed.
2. eval have correct return code there is no need in extra message
   With built-in function 'error()' is used, we can have some
   unexpected behaviour like: stat, err = pcall(error(1))
   To distinguish case with error(message) from something went bad
   suggest to use pattern "[string ...].

Closes #3560
---
Ticket: https://github.com/tarantool/tarantool/issues/3560
Branch: kbelyavs/gh-3560-tarantoolctl-eval-error-message

 extra/dist/tarantoolctl.in | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/extra/dist/tarantoolctl.in b/extra/dist/tarantoolctl.in
index f0529734f..47092fe12 100755
--- a/extra/dist/tarantoolctl.in
+++ b/extra/dist/tarantoolctl.in
@@ -749,6 +749,10 @@ local function status()
     return 0
 end
 
+string.startswith = function (self, start)
+    return self:sub(1, #start) == start
+end
+
 local function eval()
     local console_sock_path = uri.parse(console_sock).service
     local filename = arg[3]
@@ -784,8 +788,9 @@ local function eval()
         return 2
     end
     local error_response = yaml.decode(full_response)[1]
-    if type(error_response) == 'table' and error_response.error then
-        log.error("Error while reloading config:")
+    if type(error_response) == 'table' and error_response.error and
+       error_response.error:startswith("[string") then
+        log.error("Error while executing command:")
         log.error(error_response.error)
         return 3
     end
-- 
2.14.3 (Apple Git-98)





More information about the Tarantool-patches mailing list