Closed sarum9in closed 6 years ago
Have you tried what happens in wraptool if this change is applied (I'm guessing nothing since it only cares about success or failure, not how it failed)? If things keep working then this LGTM.
$ ~/meson/meson.py wrap info sdb
Warning: SSL not available, traffic not authenticated.
Traceback (most recent call last):
File "/home/user/meson/meson.py", line 29, in <module>
sys.exit(mesonmain.main())
File "/home/user/meson/mesonbuild/mesonmain.py", line 401, in main
return run(sys.argv[1:], launcher)
File "/home/user/meson/mesonbuild/mesonmain.py", line 320, in run
return wraptool.run(remaining_args)
File "/home/user/meson/mesonbuild/wrap/wraptool.py", line 224, in run
info(args[0])
File "/home/user/meson/mesonbuild/wrap/wraptool.py", line 139, in info
jd = get_result(API_ROOT + 'projects/' + name)
File "/home/user/meson/mesonbuild/wrap/wraptool.py", line 52, in get_result
u = open_wrapdburl(urlstring)
File "/home/user/meson/mesonbuild/wrap/wrap.py", line 70, in open_wrapdburl
return urllib.request.urlopen(urlstring)
File "/usr/lib/python3.6/urllib/request.py", line 223, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python3.6/urllib/request.py", line 532, in open
response = meth(req, response)
File "/usr/lib/python3.6/urllib/request.py", line 642, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib/python3.6/urllib/request.py", line 570, in error
return self._call_chain(*args)
File "/usr/lib/python3.6/urllib/request.py", line 504, in _call_chain
result = func(*args)
File "/usr/lib/python3.6/urllib/request.py", line 650, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: NOT FOUND
That is what happens. It throws an error anyway and I don't think it checks the error code:
$ git grep HTTPError
[empty result]
So basically we just change the error returned. Potentially meson core can handle it with a nicer error message, but this behavior was never documented.
Return 404 if project is not found. It is not an internal server error. Introduce a separate error class webapi.APIError() to report them. Fix #59: return no results form database wrapper if project is not found. Add a single test case for #59. TODO: test more cases.
This is technically an API change since 404 is returned instead of 500 in some cases, @jpakkane please take a look.