forked from Devsol-01/Nestera
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi-error-response.dto.ts
More file actions
91 lines (80 loc) · 2.07 KB
/
Copy pathapi-error-response.dto.ts
File metadata and controls
91 lines (80 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import { ApiProperty } from '@nestjs/swagger';
import { StandardErrorResponseDto } from './standard-error-response.dto';
export class ApiErrorResponseDto extends StandardErrorResponseDto {
@ApiProperty({
example: 'Bad Request',
description: 'Error type (deprecated, use errorCode instead)',
required: false,
})
error?: string;
}
export class ValidationErrorDto extends ApiErrorResponseDto {
@ApiProperty({
example: [
{
field: 'goalName',
value: '',
constraints: {
isNotEmpty: 'goalName should not be empty',
},
},
],
description: 'Validation errors',
})
declare errors?: Array<{
field: string;
value?: unknown;
constraints: Record<string, string>;
}>;
}
export class UnauthorizedErrorDto extends ApiErrorResponseDto {
@ApiProperty({
example: 401,
description: 'HTTP status code',
})
statusCode = 401;
@ApiProperty({
example: 'AUTH_001',
description: 'Error code',
})
errorCode = 'AUTH_001';
@ApiProperty({
example: 'Authentication required. Please provide valid credentials.',
description: 'Error message',
})
message = 'Authentication required. Please provide valid credentials.';
}
export class ForbiddenErrorDto extends ApiErrorResponseDto {
@ApiProperty({
example: 403,
description: 'HTTP status code',
})
statusCode = 403;
@ApiProperty({
example: 'AUTHZ_001',
description: 'Error code',
})
errorCode = 'AUTHZ_001';
@ApiProperty({
example: 'You do not have permission to access this resource.',
description: 'Error message',
})
message = 'You do not have permission to access this resource.';
}
export class NotFoundErrorDto extends ApiErrorResponseDto {
@ApiProperty({
example: 404,
description: 'HTTP status code',
})
statusCode = 404;
@ApiProperty({
example: 'SYS_404',
description: 'Error code',
})
errorCode = 'SYS_404';
@ApiProperty({
example: 'The requested resource was not found.',
description: 'Error message',
})
message = 'The requested resource was not found.';
}