Improve error handling
This commit is contained in:
parent
9f2cc875f9
commit
db1b48ee02
1 changed files with 4 additions and 7 deletions
|
@ -106,10 +106,6 @@ def fetch_user(user_id):
|
||||||
|
|
||||||
def fetch_top_n(n):
|
def fetch_top_n(n):
|
||||||
output = get_top_N('score', True, n)
|
output = get_top_N('score', True, n)
|
||||||
|
|
||||||
if output == '[]':
|
|
||||||
output = None
|
|
||||||
|
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
|
||||||
|
@ -126,12 +122,13 @@ def process_request(uri):
|
||||||
output = None
|
output = None
|
||||||
|
|
||||||
if len(parts) < 2:
|
if len(parts) < 2:
|
||||||
return None
|
output = None
|
||||||
|
elif parts[1] == 'users':
|
||||||
if parts[1] == 'users':
|
|
||||||
output = fetch_user(parts[2])
|
output = fetch_user(parts[2])
|
||||||
elif parts[1] == 'top':
|
elif parts[1] == 'top':
|
||||||
output = fetch_top_n(parts[2])
|
output = fetch_top_n(parts[2])
|
||||||
|
else:
|
||||||
|
output = None
|
||||||
|
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
|
Reference in a new issue