Beispiel #1
0
def error_handler(err):
    """If error occured we flash it onto screen and render index"""
    logging.exception(err)
    try:
        err.code
    except AttributeError:
        err.code = 500
        err.name = 'Internal Server Error'

    if flask.request.path.startswith('/api/'):
        return helpers.handle_error(err)

    flask.flash(err.name)
    return flask.render_template('index.html')
Beispiel #2
0
def error_handler(err):
    """If error occured we flash it onto screen and render index"""
    logging.exception(err)
    try:
        err.code
    except AttributeError:
        err.code = 500
        err.name = 'Internal Server Error'

    if flask.request.path.startswith('/api/'):
        return helpers.handle_error(err)

    flask.flash(err.name)
    return flask.render_template('index.html')
Beispiel #3
0
def error_handler(e):
    code = getattr(e, 'code', 500)
    error_name = getattr(e, 'name', 'Internal Server Error')
    logging.error('%d - %s: %s', code, error_name, flask.request.url)
    if code != 404:
        logging.exception(e)

    if flask.request.path.startswith('/api/'):
        return helpers.handle_error(e)

    return flask.render_template(
        'error.html',
        title='Error %d (%s)!!1' % (code, error_name),
        html_class='error-page',
        error=e,
    ), code
Beispiel #4
0
def error_handler(e):
	logging.exception(e)
	try:
		e.code
	except AttributeError:
		e.code = 500
		e.name = 'Internal Server Error'

	if flask.request.path.startswith('/api/'):
		return helpers.handle_error(e)

	return flask.render_template(
			'error.html',
			title='Error %d (%s)!!1' % (e.code, e.name),
			html_class='error-page',
			error=e,
	), e.code
Beispiel #5
0
def error_handler(e):
    logging.exception(e)
    try:
        e.code
    except AttributeError:
        e.code = 500
        e.name = 'Internal Server Error'

    if flask.request.path.startswith('/api/'):
        return helpers.handle_error(e)

    return flask.render_template(
        'error.html',
        title='Error %d (%s)!!1' % (e.code, e.name),
        html_class='error-page',
        error=e,
    ), e.code
Beispiel #6
0
def error_handler(e):
    if not hasattr(e, 'code') or not isinstance(e.code, int):
        e.code = 500
        e.name = 'Internal Server Error'

    logging.error('%d - %s: %s', e.code, e.name, flask.request.url)
    if e.code != 404:
        logging.exception(e)

    if flask.request.path.startswith('/api/'):
        return helpers.handle_error(e)

    return flask.render_template(
        'error.html',
        title=_('Error %(code)d (%(name)s)!!1', code=e.code, name=e.name),
        html_class='error-page',
        error=e,
    ), e.code
Beispiel #7
0
def error_handler(e):
  try:
    e.code
  except AttributeError:
    e.code = 500
    e.name = 'Internal Server Error'

  logging.error('%d - %s: %s', e.code, e.name, flask.request.url)
  if e.code != 404:
    logging.exception(e)

  if flask.request.path.startswith('/api/'):
    return helpers.handle_error(e)

  return flask.render_template(
    'error.html',
    title=_('Error %(code)d (%(name)s)!!1', code=e.code, name=e.name),
    html_class='error-page',
    error=e,
  ), e.code
def error_handler(e):
  logging.exception(e)
  try:
    e.code
  except AttributeError:
    e.code = 500
    e.name = 'Internal Server Error'

  if flask.request.path.startswith('/api/'):
    return helpers.handle_error(e)

  return flask.render_template(
      'share/error/error.html',
      model = {
        'title': 'Error %d (%s)' % (e.code, e.name),
        'html_class' : 'error-page',
        'error': e
      }

    ), e.code