Skip to content

Commit 2bf8567

Browse files
authored
Merge pull request #18 from uKaigo/add/noresults-desc
Describe NoResults errors
2 parents 33989b2 + ca0e7dd commit 2bf8567

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

ksoftapi/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
__author__ = 'AndyTempel'
99
__license__ = 'GNU'
1010
__copyright__ = 'Copyright 2018-2020 AndyTempel'
11-
__version__ = '0.4.1'
11+
__version__ = '0.4.2a'
1212

1313
import logging
1414
from collections import namedtuple
@@ -19,7 +19,7 @@
1919

2020
VersionInfo = namedtuple('VersionInfo', 'major minor micro releaselevel serial')
2121

22-
version_info = VersionInfo(major=0, minor=4, micro=1, releaselevel='alpha', serial=0)
22+
version_info = VersionInfo(major=0, minor=4, micro=2, releaselevel='alpha', serial=0)
2323

2424
try:
2525
from logging import NullHandler

ksoftapi/apis/bans.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ async def info(self, user_id: int) -> BanInfo:
122122
"""
123123
r = await self._client.http.get('/bans/info', params={'user': user_id})
124124

125-
if 'code' in r and r['code'] == 404:
126-
raise NoResults
125+
if r.get('code', 200) == 404:
126+
raise NoResults(r['message'])
127127

128128
return BanInfo(r)
129129

ksoftapi/apis/images.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ async def random_image(self, tag: str, nsfw: bool = False) -> Image:
2828
r = await self._client.http.get('/images/random-image', params={'tag': tag, 'nsfw': nsfw})
2929

3030
if r.get('code', 200) == 404:
31-
raise NoResults
31+
raise NoResults(r['message'])
3232

3333
return Image(r)
3434

@@ -92,7 +92,7 @@ async def random_reddit(self, subreddit: str, remove_nsfw: bool = False, span: s
9292
params={'remove_nsfw': remove_nsfw, 'span': span})
9393

9494
if r.get('code', 200) == 404:
95-
raise NoResults
95+
raise NoResults(r['message'])
9696

9797
return RedditImage(r)
9898

@@ -123,7 +123,7 @@ async def get_image(self, snowflake: str) -> Image:
123123
r = await self._client.http.get('/images/image/{}'.format(snowflake))
124124

125125
if r.get('code', 200) == 404:
126-
raise NoResults
126+
raise NoResults(r['message'])
127127

128128
return Image(r)
129129

@@ -143,7 +143,7 @@ async def search_tags(self, search: str) -> TagCollection:
143143
r = await self._client.http.get('/images/tags/{}'.format(search))
144144

145145
if r.get('code', 200) == 404:
146-
raise NoResults
146+
raise NoResults(r['message'])
147147

148148
return TagCollection(r)
149149

ksoftapi/apis/kumo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ async def gis(self, location: str, fast: bool = False, more: bool = False, map_z
3939
'include_map': include_map})
4040

4141
if r.get('code', 200) == 404:
42-
raise NoResults
42+
raise NoResults(r['message'])
4343

4444
result = r['data']
4545
if isinstance(result, list):
@@ -67,7 +67,7 @@ async def geoip(self, ip: str):
6767
r = await self._client.http.get('/kumo/geoip', params={'ip': ip})
6868

6969
if r.get('code', 200) == 404:
70-
raise NoResults
70+
raise NoResults(r['message'])
7171

7272
result = r['data']
7373
return IPInfo(result)

ksoftapi/apis/music.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ async def lyrics(self, query: str, text_only: bool = False, clean_up: bool = Tru
3838
results = r['data']
3939

4040
if not results:
41-
raise NoResults
41+
raise NoResults('Song not found.')
4242

4343
return [LyricResult(lr) for lr in results]
4444

@@ -82,6 +82,6 @@ async def recommendations(self, tracks: list, provider: str, youtube_token: str
8282
results = r['tracks']
8383

8484
if not results:
85-
raise NoResults
85+
raise NoResults('No recommendations.')
8686

8787
return [Recommendation(r) for r in results]

0 commit comments

Comments
 (0)