official-stockfish/fishtest

The 404 page masks error messages

Closed this issue · 3 comments

The api's in api.py sometimes return a HTTPNotFound exception (404) with a body explaining the error. This error message is no longer displayed.

Can we add the error message to the 404 page, or is this not done?

Well, this is unintended. it's a clear bug
but it's not obvious to me how to keep this custom renderer while at the same time return the error as json as before the indrocution of this new page.
I tried

@notfound_view_config(renderer="notfound.mak")
def notfound_view(request):
    if request.exception:
        return request.exception
    else:
        return {}

but it adds some additional text like (page not found) and returns the response as text rather than json..

Well I forgot to answer your question, no I don't think it's a good idea to return HTML as response for non view APIs as error.

I think one would only have to modify notfound.mak using the content of request.exception to return json if request.exception contains a json encoded dict.

EDIT: I am not sure this is the most "clever" solution but I don't understand pyramid views very well.