fixed throw error
This commit is contained in:
parent
0e8808e371
commit
1c5faecf04
1 changed files with 10 additions and 2 deletions
|
|
@ -93,7 +93,10 @@ export class RetirementService {
|
|||
}
|
||||
|
||||
} 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;
|
||||
|
|
@ -111,8 +114,13 @@ export class RetirementService {
|
|||
return;
|
||||
}
|
||||
|
||||
const retireYear = profile.leaveDate.getFullYear();
|
||||
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
|
||||
await PostRetireToExprofile(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue