fixed throw error

This commit is contained in:
Warunee Tamkoo 2026-05-08 14:45:17 +07:00
parent 0e8808e371
commit 1c5faecf04

View file

@ -93,7 +93,10 @@ export class RetirementService {
} }
} catch (error: any) { } catch (error: any) {
throw error; // Log error but don't throw - allow cronjob to complete with partial results
console.error("[cronjobPostRetireToExprofile] Error:", error);
// Return current results instead of throwing
return result;
} }
return result; return result;
@ -111,8 +114,13 @@ export class RetirementService {
return; return;
} }
const retireYear = profile.leaveDate.getFullYear();
const retireDate = new Date(profile.leaveDate); const retireDate = new Date(profile.leaveDate);
const retireYear = retireDate.getFullYear();
// Validate date is valid
if (isNaN(retireYear) || retireYear < 2000 || retireYear > 2100) {
throw new Error(`Invalid leaveDate for profile ${profile.id}: ${profile.leaveDate}`);
}
// ส่งไปยัง Exprofile // ส่งไปยัง Exprofile
await PostRetireToExprofile( await PostRetireToExprofile(