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:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user