Implemented more flexible and "Flask"-aligned way of managing custom error handler