Skip to content

Commit 62a4a58

Browse files
committed
Add NOT_FOUND_MESSAGE to adapter/question.py
1 parent 1924f14 commit 62a4a58

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

lib/adapter/question.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,25 @@
1919
from languages_data import SO_NAME
2020
from .upstream import UpstreamAdapter
2121

22+
NOT_FOUND_MESSAGE = """404 NOT FOUND
23+
24+
Unknown cheat sheet. Please try to reformulate your query.
25+
Query format:
26+
27+
/LANG/QUESTION
28+
29+
Examples:
30+
31+
/python/read+json
32+
/golang/run+external+program
33+
/js/regex+search
34+
35+
See /:help for more info.
36+
37+
If the problem persists, file a GitHub issue at
38+
github.com/chubin/cheat.sh or ping @igor_chubin
39+
"""
40+
2241
class Question(UpstreamAdapter):
2342

2443
"""
@@ -92,6 +111,10 @@ def _get_page(self, topic, request_options=None):
92111
cmd = [CONFIG["path.internal.bin.upstream"]] + topic
93112
proc = Popen(cmd, stdin=open(os.devnull, "r"), stdout=PIPE, stderr=PIPE)
94113
answer = proc.communicate()[0].decode('utf-8')
114+
115+
if not answer:
116+
return NOT_FOUND_MESSAGE
117+
95118
return answer
96119

97120
def get_list(self, prefix=None):

0 commit comments

Comments
 (0)