Python flask.g 模块,sentry_event_id() 实例源码

我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用flask.g.sentry_event_id()

项目:headers    作者:oshp    | 项目源码 | 文件源码
def page_not_found(e):
    '''Redirect HTTP 500 code to 500.html template and set objects to
    caught user feedback sent to <sentry.io>'''
    return render_template('500.html',
                           event_id=g.sentry_event_id,
                           public_dsn=sentry.client.get_public_dsn('https')
                           ), 500
项目:conditional    作者:ComputerScienceHouse    | 项目源码 | 文件源码
def route_errors(error):
    data = dict()
    username = request.headers.get('x-webauth-user')

    # Handle the case where the header isn't present
    if username is not None:
        member = ldap_get_member(username)
        data['username'] = member.uid
        data['name'] = member.cn
    else:
        data['username'] = "unknown"
        data['name'] = "Unknown"

    # Figure out what kind of error was passed
    if isinstance(error, int):
        code = error
    elif hasattr(error, 'code'):
        code = error.code
    else:
        # Unhandled exception
        code = 500

    # Is this a 404?
    if code == 404:
        error_desc = "Page Not Found"
    else:
        error_desc = type(error).__name__

    return render_template('errors.html',
                            error=error_desc,
                            error_code=code,
                            event_id=g.sentry_event_id,
                            public_dsn=sentry.client.get_public_dsn('https'),
                            **data), int(code)
项目:flask-skeleton    作者:axiaoxin    | 项目源码 | 文件源码
def server_error(error):
    data = {
        'sentry_event_id': g.sentry_event_id,
        'public_dsn': sentry.client.get_public_dsn('http')
    }
    return response(ResponseCode.SERVER_ERROR, data=data)
项目:NZ-ORCID-Hub    作者:Royal-Society-of-New-Zealand    | 项目源码 | 文件源码
def internal_error(error):
    """Handle internal error."""
    trace = traceback.format_exc()
    try:
        from . import sentry
        return render_template(
            "http500.html",
            trace=trace,
            error_message=str(error),
            event_id=g.sentry_event_id,
            public_dsn=sentry.client.get_public_dsn("https"))
    except:
        return render_template("http500.html", trace=trace, error_message=str(error))
项目:invenio-github    作者:inveniosoftware    | 项目源码 | 文件源码
def process_release(release_id, verify_sender=False):
    """Process a received Release."""
    from invenio_db import db
    from invenio_rest.errors import RESTException

    from .errors import InvalidSenderError
    from .models import Release, ReleaseStatus
    from .proxies import current_github

    release_model = Release.query.filter(
        Release.release_id == release_id,
        Release.status.in_([ReleaseStatus.RECEIVED, ReleaseStatus.FAILED]),
    ).one()
    release_model.status = ReleaseStatus.PROCESSING
    db.session.commit()

    release = current_github.release_api_class(release_model)
    if verify_sender and not release.verify_sender():
        raise InvalidSenderError(
            u'Invalid sender for event {event} for user {user}'
            .format(event=release.event.id, user=release.event.user_id)
        )

    def _get_err_obj(msg):
        """Generate the error entry with a Sentry ID."""
        err = {'errors': msg}
        if hasattr(g, 'sentry_event_id'):
            err['error_id'] = str(g.sentry_event_id)
        return err

    try:
        release.publish()
        release.model.status = ReleaseStatus.PUBLISHED
    except RESTException as rest_ex:
        release.model.errors = json.loads(rest_ex.get_body())
        release.model.status = ReleaseStatus.FAILED
        current_app.logger.exception(
            u'Error while processing {release}'.format(release=release.model))
    # TODO: We may want to handle GitHub errors differently in the future
    # except GitHubError as github_ex:
    #     release.model.errors = {'error': str(e)}
    #     release.model.status = ReleaseStatus.FAILED
    #     current_app.logger.exception(
    #         'Error while processing {release}'
    #         .format(release=release.model))
    except CustomGitHubMetadataError as e:
        release.model.errors = _get_err_obj(str(e))
        release.model.status = ReleaseStatus.FAILED
        current_app.logger.exception(
            u'Error while processing {release}'.format(release=release.model))
    except Exception:
        release.model.errors = _get_err_obj('Unknown error occured.')
        release.model.status = ReleaseStatus.FAILED
        current_app.logger.exception(
            u'Error while processing {release}'.format(release=release.model))
    finally:
        db.session.commit()