yugabyte / cqlsh

Yugabyte Cloud Query Language (YCQL) shell for YugabyteDB database
Apache License 2.0
4 stars 16 forks source link

Fixed incomplete error message #24

Closed HarshDaryani896 closed 7 months ago

HarshDaryani896 commented 8 months ago

Description Using python2.7, On running a drop keyspace query, incomplete error message is shown:

ycqlsh> drop keyspace new;
NoHostAvailable: 

Fix Quoting from https://github.com/yugabyte/cqlsh/pull/23#pullrequestreview-1867543110

- in python2.7 the message field return empty string because multiple arguments was passed to exception's object constructor
- the message field is deprecated since 2.6. In case YB is not interested in supporting python prior to 2.7 str(err) must be used instead of message field. In other case it seems reasonable to create helper function and use it everywhere

Since the supported python version are python2.7 or python3.6+ and message field is deprecated since python2.6, the fix is to simply use str(err) instead of err.message

Testing Tested locally and verified that proper error message is printed for the drop keyspace query.

ycqlsh> drop keyspace new;
NoHostAvailable: ('Unable to complete the operation against any hosts', {<Host: 127.0.0.1:9042 datacenter1>: <Error from server: code=0000 [Server error] message="Server Error. Cannot delete keyspace which has table: k [id=d98ecdf7bfd9436ca627d6c7dbd22394], request: namespace { name: "new" }: NAMESPACE_IS_NOT_EMPTY (master error 14)
drop keyspace new;
              ^^^
 (ql error -2)">})