code: def json_error_handler(exception):
      
      http_exception = isinstance(exception, exceptions.HTTPException)
      code = exception.code if http_exception else 500
  
      # log exceptions only (app debug should be off)
      if code == 500:
          current_app.logger.error(exception)
  
      response = jsonify(dict(message=str(exception)))
      response.status_code = code
      return response
docs: Json error handler
      Returns a json message for th excepion with appripriate response code and
      application/json content type.
      :param exception:
      :return: