260319:1246 Fix fronend UUID #01
Build and Deploy / deploy (push) Successful in 7m56s

This commit is contained in:
admin
2026-03-19 12:46:33 +07:00
parent e8bdd7d7fc
commit 17afe3e392
19 changed files with 265 additions and 92 deletions
@@ -39,6 +39,7 @@ export class DocumentNumberAudit {
'CANCEL',
'MANUAL_OVERRIDE',
'VOID',
'VOID_REPLACE',
'GENERATE',
],
default: 'CONFIRM',
@@ -26,6 +26,7 @@ export class DocumentNumberError {
'SEQUENCE_EXHAUSTED',
'RESERVATION_EXPIRED',
'DUPLICATE_NUMBER',
'GENERATE_ERROR',
],
})
errorType!: string;
@@ -475,17 +475,35 @@ export class DocumentNumberingService {
return (await this.auditRepo.save(audit)) as unknown as DocumentNumberAudit;
}
private async logError(error: any, ctx: any, operation: string) {
private mapErrorType(error: Error): string {
const name = error.name || '';
const msg = error.message || '';
if (name === 'ConflictException' || msg.includes('version'))
return 'VERSION_CONFLICT';
if (msg.includes('lock') || msg.includes('timeout')) return 'LOCK_TIMEOUT';
if (msg.includes('Redis') || msg.includes('redis')) return 'REDIS_ERROR';
if (msg.includes('duplicate') || msg.includes('Duplicate'))
return 'DUPLICATE_NUMBER';
if (msg.includes('validation') || msg.includes('Validation'))
return 'VALIDATION_ERROR';
if (msg.includes('exhausted') || msg.includes('maximum'))
return 'SEQUENCE_EXHAUSTED';
if (msg.includes('expired') || msg.includes('reservation'))
return 'RESERVATION_EXPIRED';
if (msg.includes('database') || msg.includes('query')) return 'DB_ERROR';
return 'GENERATE_ERROR';
}
private async logError(error: unknown, ctx: unknown, operation: string) {
try {
const err = error instanceof Error ? error : new Error(String(error));
const errEntity = this.errorRepo.create({
errorMessage: error.message || 'Unknown Error',
errorType: error.name || 'GENERATE_ERROR', // Simple mapping
errorMessage: err.message || 'Unknown Error',
errorType: this.mapErrorType(err),
contextData: {
// Mapped from context
...ctx,
...(typeof ctx === 'object' && ctx !== null ? ctx : {}),
operation,
inputPayload: JSON.stringify(ctx),
},
} as Record<string, unknown>,
});
await this.errorRepo.save(errEntity);
} catch (e) {