Audacity 3.2.0
Public Member Functions | Private Attributes | List of all members
audacity::sqlite::Error Class Referencefinal

A class representing an error in SQLite. More...

#include <Error.h>

Public Member Functions

 Error () noexcept
 
 Error (int code) noexcept
 
 Error (const Error &)=default
 
 Error (Error &&)=default
 
Erroroperator= (const Error &)=default
 
Erroroperator= (Error &&)=default
 
bool IsError () const noexcept
 Returns true if the object represents an error. More...
 
bool IsOk () const noexcept
 Returns true if the object represents a success code. More...
 
 operator bool () const noexcept
 Returns true if the object represents a success code. More...
 
void Raise () const
 
int GetCode () const noexcept
 
TranslatableString GetErrorString () const
 

Private Attributes

int mCode
 

Detailed Description

A class representing an error in SQLite.

Definition at line 16 of file Error.h.

Constructor & Destructor Documentation

◆ Error() [1/4]

audacity::sqlite::Error::Error ( )
noexcept

Definition at line 15 of file Error.cpp.

16 : mCode(SQLITE_OK)
17{
18}

◆ Error() [2/4]

audacity::sqlite::Error::Error ( int  code)
explicitnoexcept

Definition at line 20 of file Error.cpp.

21 : mCode(code)
22{
23}

◆ Error() [3/4]

audacity::sqlite::Error::Error ( const Error )
default

◆ Error() [4/4]

audacity::sqlite::Error::Error ( Error &&  )
default

Member Function Documentation

◆ GetCode()

int audacity::sqlite::Error::GetCode ( ) const
noexcept

Definition at line 50 of file Error.cpp.

51{
52 return mCode;
53}

References mCode.

◆ GetErrorString()

TranslatableString audacity::sqlite::Error::GetErrorString ( ) const

Definition at line 55 of file Error.cpp.

56{
57 switch (mCode)
58 {
59 case SQLITE_OK:
60 /* i18n-hint: database operation was successful */
61 return XO("No error");
62 case SQLITE_ERROR:
63 /* i18n-hint: database operation has failed, but there is no specific reason */
64 return XO("Generic error");
65 case SQLITE_INTERNAL:
66 /* i18n-hint: database operation has failed due to the internal error */
67 return XO("Internal logic error in SQLite");
68 case SQLITE_PERM:
69 /* i18n-hint: database operation has failed due to the permission error */
70 return XO("Access permission denied");
71 case SQLITE_ABORT:
72 /* i18n-hint: database operation was aborted by the callback */
73 return XO("Callback routine requested an abort");
74 case SQLITE_BUSY:
75 /* i18n-hint: database operation has failed because database is locked */
76 return XO("The database file is locked");
77 case SQLITE_LOCKED:
78 /* i18n-hint: database operation has failed because table is locked */
79 return XO("A table in the database is locked");
80 case SQLITE_NOMEM:
81 /* i18n-hint: database operation has failed due to the lack of memory */
82 return XO("A malloc() failed");
83 case SQLITE_READONLY:
84 /* i18n-hint: database operation has failed because database is read-only */
85 return XO("Attempt to write a read-only database");
86 case SQLITE_INTERRUPT:
87 /* i18n-hint: database operation was interrupted */
88 return XO("Operation terminated");
89 case SQLITE_IOERR:
90 /* i18n-hint: database operation has failed due to the I/O failure */
91 return XO("I/O error occurred");
92 case SQLITE_CORRUPT:
93 /* i18n-hint: database operation has failed due to the database corruption */
94 return XO("The database disk image is malformed");
95 case SQLITE_NOTFOUND:
96 /* i18n-hint: database operation has failed because the requested item was not found */
97 return XO("File not found");
98 case SQLITE_FULL:
99 /* i18n-hint: database operation has failed because the drive is full */
100 return XO("Insertion failed because the drive is full");
101 case SQLITE_CANTOPEN:
102 /* i18n-hint: database operation has failed because the file cannot be opened */
103 return XO("Unable to open the database file");
104 case SQLITE_PROTOCOL:
105 /* i18n-hint: database operation has failed because the lock protocol has failed */
106 return XO("Database lock protocol error");
107 case SQLITE_SCHEMA:
108 /* i18n-hint: database operation has failed because the database schema has changed */
109 return XO("The database schema changed");
110 case SQLITE_TOOBIG:
111 /* i18n-hint: database operation has failed because the string or BLOB exceeds size limit */
112 return XO("String or BLOB exceeds size limit");
113 case SQLITE_CONSTRAINT:
114 /* i18n-hint: database operation has failed due to the constraint violation */
115 return XO("Abort due to constraint violation");
116 case SQLITE_MISMATCH:
117 /* i18n-hint: database operation has failed due to the data type mismatch */
118 return XO("Data type mismatch");
119 case SQLITE_MISUSE:
120 /* i18n-hint: database operation has failed due to the library misuse */
121 return XO("Library used incorrectly");
122 case SQLITE_NOLFS:
123 /* i18n-hint: database operation has failed because the large file support is disabled */
124 return XO("The large file support is disabled");
125 case SQLITE_AUTH:
126 /* i18n-hint: database operation has failed due to the authorization error */
127 return XO("Authorization denied");
128 case SQLITE_FORMAT:
129 /* i18n-hint: database operation has failed due to the format error */
130 return XO("Not used");
131 case SQLITE_RANGE:
132 /* i18n-hint: database operation has failed because the parameter is out of range */
133 return XO("2nd parameter to sqlite3_bind out of range");
134 case SQLITE_NOTADB:
135 /* i18n-hint: database operation has failed because the file opened is not a database file */
136 return XO("File opened that is not a database file ");
137 default:
138 /* i18n-hint: database operation has failed due to the unknown error */
139 return XO("Unknown error");
140 }
141}
XO("Cut/Copy/Paste")

References mCode, and XO().

Here is the call graph for this function:

◆ IsError()

bool audacity::sqlite::Error::IsError ( ) const
noexcept

Returns true if the object represents an error.

Definition at line 25 of file Error.cpp.

26{
27 return mCode != SQLITE_OK && mCode != SQLITE_DONE && mCode != SQLITE_ROW;
28}

References mCode.

Referenced by audacity::sqlite::Transaction::Abort(), audacity::sqlite::Connection::Close(), audacity::sqlite::Transaction::Commit(), and IsOk().

Here is the caller graph for this function:

◆ IsOk()

bool audacity::sqlite::Error::IsOk ( ) const
noexcept

Returns true if the object represents a success code.

Definition at line 30 of file Error.cpp.

31{
32 return !IsError();
33}
bool IsError() const noexcept
Returns true if the object represents an error.
Definition: Error.cpp:25

References IsError().

Referenced by audacity::sqlite::Transaction::IsOpen().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator bool()

audacity::sqlite::Error::operator bool ( ) const
explicitnoexcept

Returns true if the object represents a success code.

Definition at line 35 of file Error.cpp.

36{
37 return IsOk();
38}
bool IsOk() const noexcept
Returns true if the object represents a success code.
Definition: Error.cpp:30

◆ operator=() [1/2]

Error & audacity::sqlite::Error::operator= ( const Error )
default

◆ operator=() [2/2]

Error & audacity::sqlite::Error::operator= ( Error &&  )
default

◆ Raise()

void audacity::sqlite::Error::Raise ( ) const

Definition at line 40 of file Error.cpp.

41{
42 assert(IsError());
43
46 Verbatim("(%d) %s").Format(GetCode(), GetErrorString()),
47 XO("SQLite3 error"));
48}
@ Internal
Indicates internal failure from Audacity.
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
Abstract base class used in importing a file.
A MessageBoxException that shows a given, unvarying string.
TranslatableString GetErrorString() const
Definition: Error.cpp:55
int GetCode() const noexcept
Definition: Error.cpp:50

References Internal, Verbatim(), and XO().

Here is the call graph for this function:

Member Data Documentation

◆ mCode

int audacity::sqlite::Error::mCode
private

Definition at line 41 of file Error.h.

Referenced by GetCode(), GetErrorString(), and IsError().


The documentation for this class was generated from the following files: