propro-common-components 0.1.283 → 0.1.285
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/main.d.ts +2 -1
- package/dist/propro-common-components.js +305 -213
- package/dist/utils/axiosInstance.d.ts +2 -0
- package/dist/utils/handleErrors.d.ts +38 -0
- package/package.json +1 -1
@@ -0,0 +1,38 @@
|
|
1
|
+
import { AxiosError } from 'axios';
|
2
|
+
|
3
|
+
export declare class AppError extends Error {
|
4
|
+
readonly context: string;
|
5
|
+
readonly originalError: Error | null;
|
6
|
+
readonly statusCode: number | null;
|
7
|
+
readonly errorType: ErrorType;
|
8
|
+
readonly timestamp: Date;
|
9
|
+
readonly metadata: Record<string, unknown>;
|
10
|
+
constructor(message: string, context: string, errorType: ErrorType, originalError?: Error | AxiosError, metadata?: Record<string, unknown>);
|
11
|
+
toJSON(): {
|
12
|
+
name: string;
|
13
|
+
message: string;
|
14
|
+
context: string;
|
15
|
+
errorType: ErrorType;
|
16
|
+
statusCode: number | null;
|
17
|
+
timestamp: Date;
|
18
|
+
metadata: Record<string, unknown>;
|
19
|
+
stack: string | undefined;
|
20
|
+
};
|
21
|
+
}
|
22
|
+
export declare enum ErrorType {
|
23
|
+
NETWORK = "NETWORK_ERROR",
|
24
|
+
API = "API_ERROR",
|
25
|
+
VALIDATION = "VALIDATION_ERROR",
|
26
|
+
AUTHENTICATION = "AUTHENTICATION_ERROR",
|
27
|
+
AUTHORIZATION = "AUTHORIZATION_ERROR",
|
28
|
+
NOT_FOUND = "NOT_FOUND_ERROR",
|
29
|
+
RATE_LIMIT = "RATE_LIMIT_ERROR",
|
30
|
+
TIMEOUT = "TIMEOUT_ERROR",
|
31
|
+
DATABASE = "DATABASE_ERROR",
|
32
|
+
EXTERNAL_SERVICE = "EXTERNAL_SERVICE_ERROR",
|
33
|
+
CONFIGURATION = "CONFIGURATION_ERROR",
|
34
|
+
UNEXPECTED = "UNEXPECTED_ERROR"
|
35
|
+
}
|
36
|
+
export declare const handleError: (error: unknown, context: string, metadata?: Record<string, unknown>) => AppError;
|
37
|
+
export declare const logError: (error: AppError) => void;
|
38
|
+
export declare const getUserFriendlyErrorMessage: (error: AppError) => string;
|