Skip to content

Commit

Permalink
Check init state before reporting stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
strseb committed Nov 14, 2022
1 parent d6c0a95 commit 31a86e6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/sentry/sentryadapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,15 @@ void SentryAdapter::init() {
logger.error() << "Sentry failed to init!";
return;
};
m_initialized = true;
logger.info() << "Sentry initialised";
}

void SentryAdapter::report(const QString& errorType, const QString& message,
bool attachStackTrace) {
if (!m_initialized) {
return;
}
sentry_value_t event = sentry_value_new_event();
sentry_value_t exc = sentry_value_new_exception(errorType.toLocal8Bit(),
message.toLocal8Bit());
Expand All @@ -87,6 +91,9 @@ void SentryAdapter::onBeforeShutdown() {
}

void SentryAdapter::onLoglineAdded(const QByteArray& line) {
if (!m_initialized) {
return;
}
// Todo: we could certainly catch this more early and format the data ?
sentry_value_t crumb =
sentry_value_new_breadcrumb("Logger", line.constData());
Expand Down
1 change: 1 addition & 0 deletions src/sentry/sentryadapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class SentryAdapter final : public QObject {
#endif

private:
m_initialized = false;
SentryAdapter();
};
#endif // SENTRYADAPTER_H

0 comments on commit 31a86e6

Please sign in to comment.