I want to raise an exception whenever i get data value as None. How can we achieve it without using custom exception?
Ex:
def foo():
<some code>
return data
@store.route("/store", methods=["GET"])
def fun():
try:
data = foo()
if not data:
raise HTTPError()
except HTTPError as he:
return "Internal server error", 500
I tried above one, but its not working, appreciate your help
>Solution :
I think sou can rais a http error as following:
from urllib2 import urlopen, HTTPError # or from urllib.error import HTTPError
def fooo():
raise HTTPError()
fooo()