working on backend-side translations

This commit is contained in:
2025-12-14 20:45:55 +01:00
parent 9fd540ba3c
commit 878365a83d
7 changed files with 85 additions and 71 deletions

View File

@@ -45,7 +45,7 @@ public class SqliteDb extends BaseDb implements ContactDb{
try {
db.prepareStatement(sql).execute();
} catch (SQLException e) {
throw databaseException(ERROR_FAILED_CREATE_TABLE,TABLE_CONTACTS);
throw databaseException(ERROR_FAILED_CREATE_TABLE,TABLE_CONTACTS).causedBy(e);
}
}
@@ -55,7 +55,7 @@ public class SqliteDb extends BaseDb implements ContactDb{
try {
db.prepareStatement(sql).execute();
} catch (SQLException e) {
throw databaseException(ERROR_FAILED_CREATE_TABLE,TABLE_CONTACTS_USERS);
throw databaseException(ERROR_FAILED_CREATE_TABLE,TABLE_CONTACTS_USERS).causedBy(e);
}
}
@@ -67,7 +67,7 @@ public class SqliteDb extends BaseDb implements ContactDb{
Query.delete().from(TABLE_CONTACTS_USERS).where(CONTACT_ID,equal(contact.id())).execute(db);
db.setAutoCommit(true);
} catch (SQLException e){
throw databaseException(FAILED_TO_DROP_ENTITY,"contact",contact.id());
throw databaseException(FAILED_TO_DROP_ENTITY,"contact",contact.id()).causedBy(e);
}
}
@@ -83,7 +83,7 @@ public class SqliteDb extends BaseDb implements ContactDb{
rs.close();
return contacts;
} catch (SQLException e) {
throw databaseException("Failed to load contacts of user {0}",userId);
throw databaseException(FAILED_TO_LOAD_CONTACTS_OF_USER,userId).causedBy(e);
}
}
@@ -97,7 +97,7 @@ public class SqliteDb extends BaseDb implements ContactDb{
if (contact != null) return contact;
throw notFound(FAILED_TO_LOAD_ENTITY_BY_ID, "contact", contactId);
} catch (SQLException e) {
throw databaseException(FAILED_TO_LOAD_CONTACTS_OF_USER,userId);
throw databaseException(FAILED_TO_LOAD_CONTACTS_OF_USER,userId).causedBy(e);
}
}
@@ -110,14 +110,14 @@ public class SqliteDb extends BaseDb implements ContactDb{
if (rs.next()) id = rs.getLong(1);
rs.close();
if (id != null) return new Contact(id,contact.vcard());
throw databaseException("Failed to store new vcard");
throw databaseException(FAILED_TO_STORE_ENTITY,"vcard");
} catch (SQLException e) {
throw databaseException("Failed to store new vcard",e);
throw databaseException(FAILED_TO_STORE_ENTITY,"vcard").causedBy(e);
}
} else try { // update
Query.update(TABLE_CONTACTS).set(DATA).where(ID,equal(contact.id())).prepare(db).apply(contact.vcard()).execute();
} catch (SQLException e) {
throw databaseException("Failed to update vcard {0}",contact.id());
throw databaseException(FAILED_TO_UPDATE_ENTITY,"vcard").causedBy(e);
}
return contact;
}
@@ -127,7 +127,7 @@ public class SqliteDb extends BaseDb implements ContactDb{
try {
Query.replaceInto(TABLE_CONTACTS_USERS,USER_ID,CONTACT_ID,ASSIGNED).values(userId,contact.id(),false).execute(db).close();
} catch (SQLException e) {
throw databaseException("Failed to assign contact {0} to user {1]",contact.id(),userId);
throw databaseException(FAILED_TO_ASSIGN_CONTACT_TO_USER,contact.id(),userId).causedBy(e);
}
}
}