felixonmars / ydcv

YouDao Console Version - Simple wrapper for Youdao online translate (Chinese <-> English) service API, as an alternative to the StarDict Console Version(sdcv).
GNU General Public License v3.0
506 stars 91 forks source link

error when network is unavailable #39

Closed Charles-Xie closed 5 years ago

Charles-Xie commented 6 years ago

when network is not connected, if I use ydcv, it will shows: Traceback (most recent call last): File "/usr/bin/ydcv", line 11, in <module> load_entry_point('ydcv==0.5', 'console_scripts', 'ydcv')() File "/usr/lib/python3.6/site-packages/ydcv.py", line 289, in main lookup_word(word) File "/usr/lib/python3.6/site-packages/ydcv.py", line 233, in lookup_word print_explanation(json.loads(data), options) File "/usr/lib/python3.6/json/__init__.py", line 354, in loads return _default_decoder.decode(s) File "/usr/lib/python3.6/json/decoder.py", line 339, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python3.6/json/decoder.py", line 357, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) Although this doesn't really affect the use of ydcv, I still hope it can be fixed, :) Just a reminder like "You network is unavailable now" will be fine.