@umituz/react-native-exception 1.2.5 → 1.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -9
- package/src/domain/repositories/IExceptionRepository.ts +26 -54
- package/src/infrastructure/storage/ExceptionStore.ts +16 -100
- package/LICENSE +0 -41
- package/README.md +0 -94
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-exception",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.7",
|
|
4
4
|
"description": "Exception handling and error tracking for React Native apps",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -33,15 +33,9 @@
|
|
|
33
33
|
"zustand": "^5.0.2",
|
|
34
34
|
"uuid": "^10.0.0",
|
|
35
35
|
"react-native-get-random-values": "^1.11.0",
|
|
36
|
-
"@umituz/react-native-design-system-theme": "*",
|
|
37
36
|
"@umituz/react-native-design-system": "*",
|
|
38
37
|
"lucide-react-native": "^0.468.0"
|
|
39
38
|
},
|
|
40
|
-
"peerDependenciesMeta": {
|
|
41
|
-
"@umituz/react-native-design-system-theme": {
|
|
42
|
-
"optional": false
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
39
|
"devDependencies": {
|
|
46
40
|
"@types/uuid": "^10.0.0",
|
|
47
41
|
"typescript": "^5.3.3",
|
|
@@ -50,7 +44,6 @@
|
|
|
50
44
|
"react": "^18.2.0",
|
|
51
45
|
"react-native": "^0.74.0",
|
|
52
46
|
"zustand": "^5.0.2",
|
|
53
|
-
"@umituz/react-native-design-system-theme": "latest",
|
|
54
47
|
"@umituz/react-native-design-system": "latest"
|
|
55
48
|
},
|
|
56
49
|
"publishConfig": {
|
|
@@ -61,4 +54,4 @@
|
|
|
61
54
|
"README.md",
|
|
62
55
|
"LICENSE"
|
|
63
56
|
]
|
|
64
|
-
}
|
|
57
|
+
}
|
|
@@ -1,65 +1,37 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Exception Repository Interface
|
|
3
|
-
* Defines
|
|
3
|
+
* Defines the contract for exception data persistence
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import type { ExceptionEntity, ErrorLog } from '../entities/ExceptionEntity';
|
|
7
7
|
|
|
8
|
-
export interface ExceptionRepositoryError
|
|
9
|
-
|
|
8
|
+
export interface ExceptionRepositoryError {
|
|
9
|
+
code: string;
|
|
10
|
+
message: string;
|
|
10
11
|
}
|
|
11
12
|
|
|
12
|
-
export type ExceptionResult<T> =
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
} | {
|
|
16
|
-
success: false;
|
|
17
|
-
error: ExceptionRepositoryError;
|
|
18
|
-
};
|
|
13
|
+
export type ExceptionResult<T> =
|
|
14
|
+
| { success: true; data: T }
|
|
15
|
+
| { success: false; error: ExceptionRepositoryError };
|
|
19
16
|
|
|
20
17
|
export interface IExceptionRepository {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Clear error logs
|
|
43
|
-
*/
|
|
44
|
-
clearErrorLogs(userId: string): Promise<ExceptionResult<boolean>>;
|
|
18
|
+
/**
|
|
19
|
+
* Save an exception to storage
|
|
20
|
+
*/
|
|
21
|
+
save(exception: ExceptionEntity): Promise<ExceptionResult<void>>;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Get all stored exceptions
|
|
25
|
+
*/
|
|
26
|
+
getAll(): Promise<ExceptionResult<ExceptionEntity[]>>;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Clear all stored exceptions
|
|
30
|
+
*/
|
|
31
|
+
clear(): Promise<ExceptionResult<void>>;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Log an error
|
|
35
|
+
*/
|
|
36
|
+
log(errorLog: ErrorLog): Promise<ExceptionResult<void>>;
|
|
45
37
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
@@ -1,114 +1,30 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Exception Store
|
|
3
|
-
*
|
|
2
|
+
* Exception Store
|
|
3
|
+
* Zustand store for exception state management
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { create } from 'zustand';
|
|
7
7
|
import type { ExceptionEntity } from '../../domain/entities/ExceptionEntity';
|
|
8
8
|
|
|
9
|
-
interface
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
errorCount: number;
|
|
14
|
-
|
|
15
|
-
// Actions
|
|
16
|
-
addException: (exception: ExceptionEntity) => void;
|
|
17
|
-
markAsHandled: (exceptionId: string) => void;
|
|
18
|
-
markAsReported: (exceptionId: string) => void;
|
|
19
|
-
clearExceptions: () => void;
|
|
20
|
-
getExceptionsByCategory: (category: string) => ExceptionEntity[];
|
|
21
|
-
getUnhandledExceptions: () => ExceptionEntity[];
|
|
9
|
+
interface ExceptionState {
|
|
10
|
+
exceptions: ExceptionEntity[];
|
|
11
|
+
addException: (exception: ExceptionEntity) => void;
|
|
12
|
+
clearExceptions: () => void;
|
|
22
13
|
}
|
|
23
14
|
|
|
24
|
-
export const useExceptionStore = create<
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
set({
|
|
32
|
-
exceptions: [exception, ...exceptions].slice(0, 100), // Keep last 100
|
|
33
|
-
lastError: exception,
|
|
34
|
-
errorCount: get().errorCount + 1,
|
|
35
|
-
});
|
|
36
|
-
},
|
|
37
|
-
|
|
38
|
-
markAsHandled: (exceptionId) => {
|
|
39
|
-
const { exceptions } = get();
|
|
40
|
-
const updated = exceptions.map((ex) =>
|
|
41
|
-
ex.id === exceptionId ? { ...ex, handled: true } : ex
|
|
42
|
-
);
|
|
43
|
-
set({ exceptions: updated });
|
|
44
|
-
},
|
|
45
|
-
|
|
46
|
-
markAsReported: (exceptionId) => {
|
|
47
|
-
const { exceptions } = get();
|
|
48
|
-
const updated = exceptions.map((ex) =>
|
|
49
|
-
ex.id === exceptionId ? { ...ex, reported: true } : ex
|
|
50
|
-
);
|
|
51
|
-
set({ exceptions: updated });
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
clearExceptions: () => set({ exceptions: [], lastError: null }),
|
|
55
|
-
|
|
56
|
-
getExceptionsByCategory: (category) => {
|
|
57
|
-
const { exceptions } = get();
|
|
58
|
-
return exceptions.filter((ex) => ex.category === category);
|
|
59
|
-
},
|
|
60
|
-
|
|
61
|
-
getUnhandledExceptions: () => {
|
|
62
|
-
const { exceptions } = get();
|
|
63
|
-
return exceptions.filter((ex) => !ex.handled);
|
|
64
|
-
},
|
|
15
|
+
export const useExceptionStore = create<ExceptionState>((set) => ({
|
|
16
|
+
exceptions: [],
|
|
17
|
+
addException: (exception) =>
|
|
18
|
+
set((state) => ({
|
|
19
|
+
exceptions: [...state.exceptions, exception],
|
|
20
|
+
})),
|
|
21
|
+
clearExceptions: () => set({ exceptions: [] }),
|
|
65
22
|
}));
|
|
66
23
|
|
|
67
24
|
/**
|
|
68
|
-
* Hook
|
|
25
|
+
* Hook to get exceptions from store
|
|
69
26
|
*/
|
|
70
27
|
export const useExceptions = () => {
|
|
71
|
-
|
|
72
|
-
exceptions
|
|
73
|
-
lastError,
|
|
74
|
-
errorCount,
|
|
75
|
-
addException,
|
|
76
|
-
markAsHandled,
|
|
77
|
-
markAsReported,
|
|
78
|
-
clearExceptions,
|
|
79
|
-
getExceptionsByCategory,
|
|
80
|
-
getUnhandledExceptions,
|
|
81
|
-
} = useExceptionStore();
|
|
82
|
-
|
|
83
|
-
return {
|
|
84
|
-
exceptions,
|
|
85
|
-
lastError,
|
|
86
|
-
errorCount,
|
|
87
|
-
addException,
|
|
88
|
-
markAsHandled,
|
|
89
|
-
markAsReported,
|
|
90
|
-
clearExceptions,
|
|
91
|
-
getExceptionsByCategory,
|
|
92
|
-
getUnhandledExceptions,
|
|
93
|
-
};
|
|
28
|
+
const exceptions = useExceptionStore((state) => state.exceptions);
|
|
29
|
+
return exceptions;
|
|
94
30
|
};
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
package/LICENSE
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Ümit UZ
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
package/README.md
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
# @umituz/react-native-exception
|
|
2
|
-
|
|
3
|
-
Exception handling and error tracking for React Native apps.
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- Centralized exception handling
|
|
8
|
-
- Error boundary component
|
|
9
|
-
- Empty state component for no data scenarios
|
|
10
|
-
- Exception store with Zustand
|
|
11
|
-
- Error categorization and severity levels
|
|
12
|
-
- Exception reporting utilities
|
|
13
|
-
|
|
14
|
-
## Installation
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
npm install @umituz/react-native-exception
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
## Peer Dependencies
|
|
21
|
-
|
|
22
|
-
- `react` >= 18.2.0
|
|
23
|
-
- `react-native` >= 0.74.0
|
|
24
|
-
- `zustand` >= 5.0.2
|
|
25
|
-
- `@umituz/react-native-design-system-theme` >= 1.0.0
|
|
26
|
-
- `@umituz/react-native-design-system` >= 1.0.0
|
|
27
|
-
|
|
28
|
-
## Usage
|
|
29
|
-
|
|
30
|
-
### Error Boundary
|
|
31
|
-
|
|
32
|
-
```typescript
|
|
33
|
-
import { ErrorBoundary } from '@umituz/react-native-exception';
|
|
34
|
-
|
|
35
|
-
<ErrorBoundary>
|
|
36
|
-
<YourApp />
|
|
37
|
-
</ErrorBoundary>
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
### Exception Service
|
|
41
|
-
|
|
42
|
-
```typescript
|
|
43
|
-
import { exceptionService } from '@umituz/react-native-exception';
|
|
44
|
-
|
|
45
|
-
try {
|
|
46
|
-
// Your code
|
|
47
|
-
} catch (error) {
|
|
48
|
-
exceptionService.handleException(
|
|
49
|
-
error,
|
|
50
|
-
'error',
|
|
51
|
-
'business-logic',
|
|
52
|
-
{ userId: '123' }
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
### Exception Store
|
|
58
|
-
|
|
59
|
-
```typescript
|
|
60
|
-
import { useExceptionStore } from '@umituz/react-native-exception';
|
|
61
|
-
|
|
62
|
-
const { exceptions, lastError } = useExceptionStore();
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
### Empty State
|
|
66
|
-
|
|
67
|
-
```typescript
|
|
68
|
-
import { EmptyState } from '@umituz/react-native-exception';
|
|
69
|
-
|
|
70
|
-
<EmptyState
|
|
71
|
-
icon="inbox"
|
|
72
|
-
title="No items found"
|
|
73
|
-
description="Start by adding your first item"
|
|
74
|
-
actionLabel="Add Item"
|
|
75
|
-
onAction={() => navigation.navigate('Add')}
|
|
76
|
-
/>
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
## License
|
|
80
|
-
|
|
81
|
-
MIT
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|