So I am making a website and would like to handle all errors for the client and server side.
I tried looking at the solution from How can I implement a custom error handler for all HTTP errors in Flask?
I changed it to my needs
@app.errorhandler(range(400, 499))
then got an output that said that it had to be a class..
Then I remember that it's not a if statement!
I am currently left with this:
@app.errorhandler(range(400, 599))
def uhoh(error):
return returnerr("Sorry, we encountered an error.. Us robots don't know what this means: " + error + ".. Sorry :/", error.code)
My returnerr function:
def returnerr(msg, code):
return render_template("error.html", msg=msg, code=code)
Any solutions? P.S. I can't do a for loop, as I am unsure how to except all general http errors.. I am also new to flask Thanks :)