MCPcopy Create free account
hub / github.com/WiseLibs/better-sqlite3 / TakeErrorMessage

Method TakeErrorMessage

src/util/fd-vfs.cpp:169–177  ·  view source on GitHub ↗

SQLite has no way for a VFS to provide an error message, so when this VFS fails with a specific reason, it records the message on the connection's main database File. This returns (and clears) that message, but only if the given error code matches and the message was recorded during the current operation (otherwise, it's left over from an error that was never reported, such as one that SQLite hand

Source from the content-addressed store, hash-verified

167 // It returns NULL for connections that don't use this VFS. The caller
168 // must hold the database connection's mutex (if any).
169 static const char* TakeErrorMessage(sqlite3* db_handle, int code) {
170 sqlite3_file* f = NULL;
171 if (sqlite3_file_control(db_handle, "main", SQLITE_FCNTL_FILE_POINTER, &f) != SQLITE_OK) return NULL;
172 if (f == NULL || f->pMethods != &main_io_methods) return NULL;
173 File* file = reinterpret_cast<File*>(f);
174 const char* message = file->error_code == code && file->error_operation == operation ? file->error_message : NULL;
175 ClearError(file);
176 return message;
177 }
178
179private:
180

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected