Enhance FalukantService error handling for debtors prison records: Implement try-catch logic to manage potential database errors when retrieving debtor records. Update nobility title requirements to include new house position values for various titles, ensuring consistency across the application. Adjust initialization script for title requirements to reflect these changes.

This commit is contained in:
Torsten Schulz (local)
2026-03-23 12:05:26 +01:00
parent 9b88a98a20
commit 42e894d4e4
3 changed files with 58 additions and 30 deletions

View File

@@ -5205,10 +5205,28 @@ class FalukantService extends BaseService {
return this.serializeDebtorsPrisonRecord(null);
}
const records = await DebtorsPrism.findAll({
where: { characterId: character.id },
order: [['createdAt', 'DESC']]
});
let records = [];
try {
records = await DebtorsPrism.findAll({
where: { characterId: character.id },
order: [['createdAt', 'DESC']]
});
} catch (error) {
const message = String(error?.original?.message || error?.message || '');
const missingLegacyDebtColumn =
message.includes('column') &&
message.includes('status') &&
message.includes('debtors_prism');
if (!missingLegacyDebtColumn) {
throw error;
}
// Production can temporarily lag behind the expanded debtors_prism schema.
// In that case we degrade to "no active debtors prison state" instead of
// breaking unrelated Falukant endpoints such as family or gifts.
records = [];
}
const activeRecord = records.find((record) => record.status !== 'released' && !record.releasedAt)
|| records[0]