0

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 :)

Spacehold
  • 106
  • 2
  • 13

1 Answers1

0

Alright, I found a way..

@app.errorhandler(Exception)
def all_exception_handler(error):

return "Error: " + error.code

Thanks to How to intercept all exceptions in flask?

Spacehold
  • 106
  • 2
  • 13