@umituz/react-native-exception 1.2.5 → 1.2.6
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-exception",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.6",
|
|
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
|
+
}
|
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
|
-
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Exception Repository Interface
|
|
3
|
-
* Defines contracts for error logging and reporting
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type { ExceptionEntity, ErrorLog } from '../entities/ExceptionEntity';
|
|
7
|
-
|
|
8
|
-
export interface ExceptionRepositoryError extends Error {
|
|
9
|
-
code: 'LOG_FAILED' | 'REPORT_FAILED' | 'FETCH_FAILED';
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export type ExceptionResult<T> = {
|
|
13
|
-
success: true;
|
|
14
|
-
data: T;
|
|
15
|
-
} | {
|
|
16
|
-
success: false;
|
|
17
|
-
error: ExceptionRepositoryError;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export interface IExceptionRepository {
|
|
21
|
-
/**
|
|
22
|
-
* Log an exception
|
|
23
|
-
*/
|
|
24
|
-
logException(exception: ExceptionEntity): Promise<ExceptionResult<ErrorLog>>;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Report exception to external service (e.g., Sentry)
|
|
28
|
-
*/
|
|
29
|
-
reportException(exception: ExceptionEntity): Promise<ExceptionResult<boolean>>;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Get error logs for a user
|
|
33
|
-
*/
|
|
34
|
-
getErrorLogs(userId: string, limit?: number): Promise<ExceptionResult<ErrorLog[]>>;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Get recent exceptions
|
|
38
|
-
*/
|
|
39
|
-
getRecentExceptions(limit?: number): Promise<ExceptionResult<ExceptionEntity[]>>;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Clear error logs
|
|
43
|
-
*/
|
|
44
|
-
clearErrorLogs(userId: string): Promise<ExceptionResult<boolean>>;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Exception Store - Zustand State Management
|
|
3
|
-
* Global exception tracking and error state
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { create } from 'zustand';
|
|
7
|
-
import type { ExceptionEntity } from '../../domain/entities/ExceptionEntity';
|
|
8
|
-
|
|
9
|
-
interface ExceptionStore {
|
|
10
|
-
// State
|
|
11
|
-
exceptions: ExceptionEntity[];
|
|
12
|
-
lastError: ExceptionEntity | null;
|
|
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[];
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const useExceptionStore = create<ExceptionStore>((set, get) => ({
|
|
25
|
-
exceptions: [],
|
|
26
|
-
lastError: null,
|
|
27
|
-
errorCount: 0,
|
|
28
|
-
|
|
29
|
-
addException: (exception) => {
|
|
30
|
-
const { exceptions } = get();
|
|
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
|
-
},
|
|
65
|
-
}));
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Hook for accessing exception state
|
|
69
|
-
*/
|
|
70
|
-
export const useExceptions = () => {
|
|
71
|
-
const {
|
|
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
|
-
};
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|