forked from Shared/esg
38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
|
|
/**
|
|
* Standardized error shape returned to API consumers
|
|
* regardless of upstream provider error formats.
|
|
*/
|
|
export class NormalizedErrorDto {
|
|
@ApiProperty({ example: 'PROVIDER_TIMEOUT' })
|
|
code!: string;
|
|
|
|
@ApiProperty({ example: 'Provider request timed out' })
|
|
message!: string;
|
|
|
|
@ApiPropertyOptional({ example: 'سرویس در دسترس نیست' })
|
|
providerMessage?: string;
|
|
|
|
@ApiPropertyOptional({ example: '503' })
|
|
providerCode?: string;
|
|
|
|
@ApiPropertyOptional({
|
|
example: 'MjFiNDQwYjAtOTdkMy00YjFkLWEzN2UtMWEyOTk2NDE0MjRm',
|
|
description: 'Upstream provider reference code when available',
|
|
})
|
|
providerTrackingCode?: string;
|
|
|
|
@ApiPropertyOptional({
|
|
example: [{ field: 'sheba', constraints: ['sheba must start with IR and contain 24 digits'] }],
|
|
description: 'Field-level validation errors when code is VALIDATION_ERROR',
|
|
})
|
|
details?: Array<{ field: string; constraints: string[] }>;
|
|
|
|
@ApiPropertyOptional({
|
|
example: { nationalCode: '4311402422', NtnlId: '0015790231' },
|
|
description: 'Conflicting values when submitted data does not match provider result',
|
|
})
|
|
conflict?: Record<string, string>;
|
|
}
|