Tarantool development patches archive
 help / color / mirror / Atom feed
* [tarantool-patches] [PATCH] tarantoolctl: update confusing error message
@ 2018-08-09 14:18 Konstantin Belyavskiy
  2018-08-20 17:03 ` Vladimir Davydov
  0 siblings, 1 reply; 2+ messages in thread
From: Konstantin Belyavskiy @ 2018-08-09 14:18 UTC (permalink / raw)
  To: tarantool-patches

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)

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

end of thread, other threads:[~2018-08-20 17:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-09 14:18 [tarantool-patches] [PATCH] tarantoolctl: update confusing error message Konstantin Belyavskiy
2018-08-20 17:03 ` Vladimir Davydov

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