TBoldUniDACConnection.GetDatabaseError (Source/Persistence/UniDAC/BoldUniDACInterfaces.pas) translates a UniDAC exception into Bold's EBoldDatabaseError. It has error-code tables for SQL Server, InterBase and PostgreSQL, and for every other provider it raises Exception.Create('Error codes not implemented for ' + ProviderName). Found while adding SQLite to the UniDAC test setup.
Symptom
On any provider outside those three (SQLite here), every database error reaching the adapter's except blocks is replaced by "Error codes not implemented for SQLite". The real error - in this case no such table: BOLD_TYPE - never surfaces, so the failure cannot be diagnosed.
Root cause
GetDatabaseError is called from inside except handlers (ExecSQL, Open, Reopen, Close). A translator that raises its own exception there discards the exception it was asked to translate. The FireDAC adapter shows the intended default: no provider table, every error becomes a generic EBoldDatabaseError carrying class, code and message.
Fix
GetDatabaseError: providers without a code table fall through with bdetError; the generic path already includes sErrorDetail (class, ErrorCode, message). The raise is gone.
- No SQLite table was added: mapping
SQLITE_CONSTRAINT (19) to bdetUpdate would produce the fixed text "Failed to update database" and lose the original message, which is exactly the defect in another form. Retry classification for SQLITE_BUSY/SQLITE_LOCKED can be a separate decision if the SQLite runs show a need.
Files changed
Source/Persistence/UniDAC/BoldUniDACInterfaces.pas
UnitTest/Code/Persistence/UniDAC/Test.PersistenceUniDAC.pas
Testing
TBoldUniDACConnection.GetDatabaseError(Source/Persistence/UniDAC/BoldUniDACInterfaces.pas) translates a UniDAC exception into Bold'sEBoldDatabaseError. It has error-code tables for SQL Server, InterBase and PostgreSQL, and for every other provider it raisesException.Create('Error codes not implemented for ' + ProviderName). Found while adding SQLite to the UniDAC test setup.Symptom
On any provider outside those three (SQLite here), every database error reaching the adapter's
exceptblocks is replaced by "Error codes not implemented for SQLite". The real error - in this caseno such table: BOLD_TYPE- never surfaces, so the failure cannot be diagnosed.Root cause
GetDatabaseErroris called from insideexcepthandlers (ExecSQL,Open,Reopen,Close). A translator that raises its own exception there discards the exception it was asked to translate. The FireDAC adapter shows the intended default: no provider table, every error becomes a genericEBoldDatabaseErrorcarrying class, code and message.Fix
GetDatabaseError: providers without a code table fall through withbdetError; the generic path already includessErrorDetail(class,ErrorCode, message). The raise is gone.SQLITE_CONSTRAINT(19) tobdetUpdatewould produce the fixed text "Failed to update database" and lose the original message, which is exactly the defect in another form. Retry classification forSQLITE_BUSY/SQLITE_LOCKEDcan be a separate decision if the SQLite runs show a need.Files changed
Source/Persistence/UniDAC/BoldUniDACInterfaces.pasUnitTest/Code/Persistence/UniDAC/Test.PersistenceUniDAC.pasTesting
TestGetDatabaseErrorKeepsTheOriginalErrorForProvidersWithoutCodeMap(aTUniConnectionwithProviderName = 'SQLite', never opened;EUniErrorwrappingEDAError(19, 'UNIQUE constraint failed ...')) failed with "Error codes not implemented for SQLite"EBoldDatabaseErrormessage