mirror of
https://github.com/cookiengineer/audacity
synced 2026-03-07 06:55:52 +01:00
Adds context to SQLite3 exceptions
This commit is contained in:
committed by
Dmitry Vedenko
parent
690772ccb0
commit
950d170ae6
@@ -18,6 +18,8 @@ Paul Licameli -- split from SampleBlock.cpp and SampleBlock.h
|
||||
|
||||
#include "SampleBlock.h" // to inherit
|
||||
|
||||
#include "SentryHelper.h"
|
||||
|
||||
class SqliteSampleBlockFactory;
|
||||
|
||||
///\brief Implementation of @ref SampleBlock using Sqlite database
|
||||
@@ -557,6 +559,10 @@ size_t SqliteSampleBlock::GetBlob(void *dest,
|
||||
// preconditions; should return SQL_OK which is 0
|
||||
if (sqlite3_bind_int64(stmt, 1, mBlockID))
|
||||
{
|
||||
ADD_EXCEPTION_CONTEXT(
|
||||
"sqlite3.rc", std::to_string(sqlite3_errcode(Conn()->DB())));
|
||||
ADD_EXCEPTION_CONTEXT("sqlite3.context", "SqliteSampleBlock::GetBlob::bind");
|
||||
|
||||
wxASSERT_MSG(false, wxT("Binding failed...bug!!!"));
|
||||
}
|
||||
|
||||
@@ -564,6 +570,9 @@ size_t SqliteSampleBlock::GetBlob(void *dest,
|
||||
rc = sqlite3_step(stmt);
|
||||
if (rc != SQLITE_ROW)
|
||||
{
|
||||
ADD_EXCEPTION_CONTEXT("sqlite3.rc", std::to_string(rc));
|
||||
ADD_EXCEPTION_CONTEXT("sqlite3.context", "SqliteSampleBlock::GetBlob::step");
|
||||
|
||||
wxLogDebug(wxT("SqliteSampleBlock::GetBlob - SQLITE error %s"), sqlite3_errmsg(db));
|
||||
|
||||
// Clear statement bindings and rewind statement
|
||||
@@ -675,6 +684,10 @@ void SqliteSampleBlock::Load(SampleBlockID sbid)
|
||||
// preconditions; should return SQL_OK which is 0
|
||||
if (sqlite3_bind_int64(stmt, 1, sbid))
|
||||
{
|
||||
|
||||
ADD_EXCEPTION_CONTEXT("sqlite3.rc", std::to_string(sqlite3_errcode(Conn()->DB())));
|
||||
ADD_EXCEPTION_CONTEXT("sqlite3.context", "SqliteSampleBlock::Load::bind");
|
||||
|
||||
wxASSERT_MSG(false, wxT("Binding failed...bug!!!"));
|
||||
}
|
||||
|
||||
@@ -682,6 +695,11 @@ void SqliteSampleBlock::Load(SampleBlockID sbid)
|
||||
rc = sqlite3_step(stmt);
|
||||
if (rc != SQLITE_ROW)
|
||||
{
|
||||
|
||||
ADD_EXCEPTION_CONTEXT("sqlite3.rc", std::to_string(rc));
|
||||
ADD_EXCEPTION_CONTEXT("sqlite3.context", "SqliteSampleBlock::Load::step");
|
||||
|
||||
|
||||
wxLogDebug(wxT("SqliteSampleBlock::Load - SQLITE error %s"), sqlite3_errmsg(db));
|
||||
|
||||
// Clear statement bindings and rewind statement
|
||||
@@ -734,6 +752,12 @@ void SqliteSampleBlock::Commit(Sizes sizes)
|
||||
sqlite3_bind_blob(stmt, 6, mSummary64k.get(), mSummary64kBytes, SQLITE_STATIC) ||
|
||||
sqlite3_bind_blob(stmt, 7, mSamples.get(), mSampleBytes, SQLITE_STATIC))
|
||||
{
|
||||
|
||||
ADD_EXCEPTION_CONTEXT(
|
||||
"sqlite3.rc", std::to_string(sqlite3_errcode(Conn()->DB())));
|
||||
ADD_EXCEPTION_CONTEXT("sqlite3.context", "SqliteSampleBlock::Commit::bind");
|
||||
|
||||
|
||||
wxASSERT_MSG(false, wxT("Binding failed...bug!!!"));
|
||||
}
|
||||
|
||||
@@ -741,6 +765,9 @@ void SqliteSampleBlock::Commit(Sizes sizes)
|
||||
rc = sqlite3_step(stmt);
|
||||
if (rc != SQLITE_DONE)
|
||||
{
|
||||
ADD_EXCEPTION_CONTEXT("sqlite3.rc", std::to_string(rc));
|
||||
ADD_EXCEPTION_CONTEXT("sqlite3.context", "SqliteSampleBlock::Commit::step");
|
||||
|
||||
wxLogDebug(wxT("SqliteSampleBlock::Commit - SQLITE error %s"), sqlite3_errmsg(db));
|
||||
|
||||
// Clear statement bindings and rewind statement
|
||||
@@ -783,6 +810,10 @@ void SqliteSampleBlock::Delete()
|
||||
// preconditions; should return SQL_OK which is 0
|
||||
if (sqlite3_bind_int64(stmt, 1, mBlockID))
|
||||
{
|
||||
ADD_EXCEPTION_CONTEXT(
|
||||
"sqlite3.rc", std::to_string(sqlite3_errcode(Conn()->DB())));
|
||||
ADD_EXCEPTION_CONTEXT("sqlite3.context", "SqliteSampleBlock::Delete::bind");
|
||||
|
||||
wxASSERT_MSG(false, wxT("Binding failed...bug!!!"));
|
||||
}
|
||||
|
||||
@@ -790,6 +821,9 @@ void SqliteSampleBlock::Delete()
|
||||
rc = sqlite3_step(stmt);
|
||||
if (rc != SQLITE_DONE)
|
||||
{
|
||||
ADD_EXCEPTION_CONTEXT("sqlite3.rc", std::to_string(rc));
|
||||
ADD_EXCEPTION_CONTEXT("sqlite3.context", "SqliteSampleBlock::Delete::step");
|
||||
|
||||
wxLogDebug(wxT("SqliteSampleBlock::Load - SQLITE error %s"), sqlite3_errmsg(db));
|
||||
|
||||
// Clear statement bindings and rewind statement
|
||||
@@ -995,3 +1029,4 @@ static struct Injector
|
||||
);
|
||||
}
|
||||
} injector;
|
||||
|
||||
Reference in New Issue
Block a user