@umituz/react-native-exception 1.0.0 → 1.0.1
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/LICENSE +7 -0
- package/README.md +7 -0
- package/package.json +7 -10
- package/src/domain/entities/ExceptionEntity.ts +7 -0
- package/src/domain/repositories/IExceptionRepository.ts +7 -0
- package/src/index.ts +7 -0
- package/src/infrastructure/services/ExceptionService.ts +7 -0
- package/src/infrastructure/storage/ExceptionStore.ts +7 -0
- package/src/presentation/components/ErrorBoundary.tsx +8 -1
- package/lib/domain/entities/ExceptionEntity.d.ts +0 -47
- package/lib/domain/entities/ExceptionEntity.js +0 -56
- package/lib/domain/repositories/IExceptionRepository.d.ts +0 -37
- package/lib/domain/repositories/IExceptionRepository.js +0 -6
- package/lib/index.d.ts +0 -14
- package/lib/index.js +0 -32
- package/lib/infrastructure/services/ExceptionService.d.ts +0 -39
- package/lib/infrastructure/services/ExceptionService.js +0 -76
- package/lib/infrastructure/storage/ExceptionStore.d.ts +0 -32
- package/lib/infrastructure/storage/ExceptionStore.js +0 -58
- package/lib/presentation/components/ErrorBoundary.d.ts +0 -21
- package/lib/presentation/components/ErrorBoundary.js +0 -127
package/LICENSE
CHANGED
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-exception",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Exception handling and error tracking for React Native apps",
|
|
5
|
-
"main": "./
|
|
6
|
-
"types": "./
|
|
5
|
+
"main": "./src/index.ts",
|
|
6
|
+
"types": "./src/index.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "tsc",
|
|
9
9
|
"typecheck": "tsc --noEmit",
|
|
10
10
|
"lint": "tsc --noEmit",
|
|
11
11
|
"clean": "rm -rf lib",
|
|
12
12
|
"prebuild": "npm run clean",
|
|
13
|
-
"prepublishOnly": "npm run build",
|
|
14
13
|
"version:patch": "npm version patch -m 'chore: release v%s'",
|
|
15
14
|
"version:minor": "npm version minor -m 'chore: release v%s'",
|
|
16
15
|
"version:major": "npm version major -m 'chore: release v%s'"
|
|
@@ -23,7 +22,7 @@
|
|
|
23
22
|
"error-boundary",
|
|
24
23
|
"crash-reporting"
|
|
25
24
|
],
|
|
26
|
-
"author": "
|
|
25
|
+
"author": "\u00dcmit UZ <umit@umituz.com>",
|
|
27
26
|
"license": "MIT",
|
|
28
27
|
"repository": {
|
|
29
28
|
"type": "git",
|
|
@@ -33,10 +32,10 @@
|
|
|
33
32
|
"react": ">=18.2.0",
|
|
34
33
|
"react-native": ">=0.74.0",
|
|
35
34
|
"zustand": "^5.0.2",
|
|
36
|
-
"@umituz/react-native-
|
|
35
|
+
"@umituz/react-native-theme": "*"
|
|
37
36
|
},
|
|
38
37
|
"peerDependenciesMeta": {
|
|
39
|
-
"@umituz/react-native-
|
|
38
|
+
"@umituz/react-native-theme": {
|
|
40
39
|
"optional": false
|
|
41
40
|
}
|
|
42
41
|
},
|
|
@@ -47,16 +46,14 @@
|
|
|
47
46
|
"react": "^18.2.0",
|
|
48
47
|
"react-native": "^0.74.0",
|
|
49
48
|
"zustand": "^5.0.2",
|
|
50
|
-
"@umituz/react-native-
|
|
49
|
+
"@umituz/react-native-theme": "latest"
|
|
51
50
|
},
|
|
52
51
|
"publishConfig": {
|
|
53
52
|
"access": "public"
|
|
54
53
|
},
|
|
55
54
|
"files": [
|
|
56
|
-
"lib",
|
|
57
55
|
"src",
|
|
58
56
|
"README.md",
|
|
59
57
|
"LICENSE"
|
|
60
58
|
]
|
|
61
59
|
}
|
|
62
|
-
|
package/src/index.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import React, { Component, ReactNode } from 'react';
|
|
7
7
|
import { View, Text, StyleSheet, TouchableOpacity } from 'react-native';
|
|
8
8
|
import { exceptionService } from '../../infrastructure/services/ExceptionService';
|
|
9
|
-
import { useAppDesignTokens } from '@umituz/react-native-
|
|
9
|
+
import { useAppDesignTokens } from '@umituz/react-native-theme';
|
|
10
10
|
|
|
11
11
|
interface Props {
|
|
12
12
|
children: ReactNode;
|
|
@@ -120,3 +120,10 @@ const getStyles = (tokens: ReturnType<typeof useAppDesignTokens>) =>
|
|
|
120
120
|
},
|
|
121
121
|
});
|
|
122
122
|
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Exception Entity - Domain Layer
|
|
3
|
-
* Pure business logic representation of errors and exceptions
|
|
4
|
-
*/
|
|
5
|
-
export type ExceptionSeverity = 'fatal' | 'error' | 'warning' | 'info';
|
|
6
|
-
export type ExceptionCategory = 'network' | 'validation' | 'authentication' | 'authorization' | 'business-logic' | 'system' | 'storage' | 'unknown';
|
|
7
|
-
export interface ExceptionContext {
|
|
8
|
-
userId?: string;
|
|
9
|
-
screen?: string;
|
|
10
|
-
action?: string;
|
|
11
|
-
componentStack?: string;
|
|
12
|
-
metadata?: Record<string, any>;
|
|
13
|
-
}
|
|
14
|
-
export interface ExceptionEntity {
|
|
15
|
-
id: string;
|
|
16
|
-
message: string;
|
|
17
|
-
stack?: string;
|
|
18
|
-
severity: ExceptionSeverity;
|
|
19
|
-
category: ExceptionCategory;
|
|
20
|
-
context: ExceptionContext;
|
|
21
|
-
timestamp: Date;
|
|
22
|
-
handled: boolean;
|
|
23
|
-
reported: boolean;
|
|
24
|
-
}
|
|
25
|
-
export interface ErrorLog {
|
|
26
|
-
id: string;
|
|
27
|
-
exceptionId: string;
|
|
28
|
-
userId?: string;
|
|
29
|
-
message: string;
|
|
30
|
-
stack?: string;
|
|
31
|
-
severity: ExceptionSeverity;
|
|
32
|
-
category: ExceptionCategory;
|
|
33
|
-
context: ExceptionContext;
|
|
34
|
-
createdAt: Date;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Factory function to create an exception entity
|
|
38
|
-
*/
|
|
39
|
-
export declare function createException(error: Error, severity?: ExceptionSeverity, category?: ExceptionCategory, context?: ExceptionContext): ExceptionEntity;
|
|
40
|
-
/**
|
|
41
|
-
* Factory function to create an error log
|
|
42
|
-
*/
|
|
43
|
-
export declare function createErrorLog(exception: ExceptionEntity): ErrorLog;
|
|
44
|
-
/**
|
|
45
|
-
* Determine if exception should be reported
|
|
46
|
-
*/
|
|
47
|
-
export declare function shouldReportException(exception: ExceptionEntity): boolean;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Exception Entity - Domain Layer
|
|
4
|
-
* Pure business logic representation of errors and exceptions
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.createException = createException;
|
|
8
|
-
exports.createErrorLog = createErrorLog;
|
|
9
|
-
exports.shouldReportException = shouldReportException;
|
|
10
|
-
/**
|
|
11
|
-
* Factory function to create an exception entity
|
|
12
|
-
*/
|
|
13
|
-
function createException(error, severity = 'error', category = 'unknown', context = {}) {
|
|
14
|
-
return {
|
|
15
|
-
id: crypto.randomUUID(),
|
|
16
|
-
message: error.message,
|
|
17
|
-
stack: error.stack,
|
|
18
|
-
severity,
|
|
19
|
-
category,
|
|
20
|
-
context,
|
|
21
|
-
timestamp: new Date(),
|
|
22
|
-
handled: false,
|
|
23
|
-
reported: false,
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Factory function to create an error log
|
|
28
|
-
*/
|
|
29
|
-
function createErrorLog(exception) {
|
|
30
|
-
return {
|
|
31
|
-
id: crypto.randomUUID(),
|
|
32
|
-
exceptionId: exception.id,
|
|
33
|
-
userId: exception.context.userId,
|
|
34
|
-
message: exception.message,
|
|
35
|
-
stack: exception.stack,
|
|
36
|
-
severity: exception.severity,
|
|
37
|
-
category: exception.category,
|
|
38
|
-
context: exception.context,
|
|
39
|
-
createdAt: new Date(),
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Determine if exception should be reported
|
|
44
|
-
*/
|
|
45
|
-
function shouldReportException(exception) {
|
|
46
|
-
// Don't report warnings or info
|
|
47
|
-
if (exception.severity === 'warning' || exception.severity === 'info') {
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
// Don't report validation errors (user errors)
|
|
51
|
-
if (exception.category === 'validation') {
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
// Report everything else
|
|
55
|
-
return true;
|
|
56
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Exception Repository Interface
|
|
3
|
-
* Defines contracts for error logging and reporting
|
|
4
|
-
*/
|
|
5
|
-
import type { ExceptionEntity, ErrorLog } from '../entities/ExceptionEntity';
|
|
6
|
-
export interface ExceptionRepositoryError extends Error {
|
|
7
|
-
code: 'LOG_FAILED' | 'REPORT_FAILED' | 'FETCH_FAILED';
|
|
8
|
-
}
|
|
9
|
-
export type ExceptionResult<T> = {
|
|
10
|
-
success: true;
|
|
11
|
-
data: T;
|
|
12
|
-
} | {
|
|
13
|
-
success: false;
|
|
14
|
-
error: ExceptionRepositoryError;
|
|
15
|
-
};
|
|
16
|
-
export interface IExceptionRepository {
|
|
17
|
-
/**
|
|
18
|
-
* Log an exception
|
|
19
|
-
*/
|
|
20
|
-
logException(exception: ExceptionEntity): Promise<ExceptionResult<ErrorLog>>;
|
|
21
|
-
/**
|
|
22
|
-
* Report exception to external service (e.g., Sentry)
|
|
23
|
-
*/
|
|
24
|
-
reportException(exception: ExceptionEntity): Promise<ExceptionResult<boolean>>;
|
|
25
|
-
/**
|
|
26
|
-
* Get error logs for a user
|
|
27
|
-
*/
|
|
28
|
-
getErrorLogs(userId: string, limit?: number): Promise<ExceptionResult<ErrorLog[]>>;
|
|
29
|
-
/**
|
|
30
|
-
* Get recent exceptions
|
|
31
|
-
*/
|
|
32
|
-
getRecentExceptions(limit?: number): Promise<ExceptionResult<ExceptionEntity[]>>;
|
|
33
|
-
/**
|
|
34
|
-
* Clear error logs
|
|
35
|
-
*/
|
|
36
|
-
clearErrorLogs(userId: string): Promise<ExceptionResult<boolean>>;
|
|
37
|
-
}
|
package/lib/index.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @umituz/react-native-exception - Public API
|
|
3
|
-
*
|
|
4
|
-
* Exception handling and error tracking for React Native apps
|
|
5
|
-
*
|
|
6
|
-
* Usage:
|
|
7
|
-
* import { ErrorBoundary, exceptionService, useExceptionStore } from '@umituz/react-native-exception';
|
|
8
|
-
*/
|
|
9
|
-
export type { ExceptionEntity, ErrorLog, ExceptionContext, ExceptionSeverity, ExceptionCategory, } from './domain/entities/ExceptionEntity';
|
|
10
|
-
export { createException, createErrorLog, shouldReportException, } from './domain/entities/ExceptionEntity';
|
|
11
|
-
export type { IExceptionRepository, ExceptionRepositoryError, ExceptionResult, } from './domain/repositories/IExceptionRepository';
|
|
12
|
-
export { useExceptionStore, useExceptions } from './infrastructure/storage/ExceptionStore';
|
|
13
|
-
export { ExceptionService, exceptionService } from './infrastructure/services/ExceptionService';
|
|
14
|
-
export { ErrorBoundary } from './presentation/components/ErrorBoundary';
|
package/lib/index.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @umituz/react-native-exception - Public API
|
|
4
|
-
*
|
|
5
|
-
* Exception handling and error tracking for React Native apps
|
|
6
|
-
*
|
|
7
|
-
* Usage:
|
|
8
|
-
* import { ErrorBoundary, exceptionService, useExceptionStore } from '@umituz/react-native-exception';
|
|
9
|
-
*/
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.ErrorBoundary = exports.exceptionService = exports.ExceptionService = exports.useExceptions = exports.useExceptionStore = exports.shouldReportException = exports.createErrorLog = exports.createException = void 0;
|
|
12
|
-
var ExceptionEntity_1 = require("./domain/entities/ExceptionEntity");
|
|
13
|
-
Object.defineProperty(exports, "createException", { enumerable: true, get: function () { return ExceptionEntity_1.createException; } });
|
|
14
|
-
Object.defineProperty(exports, "createErrorLog", { enumerable: true, get: function () { return ExceptionEntity_1.createErrorLog; } });
|
|
15
|
-
Object.defineProperty(exports, "shouldReportException", { enumerable: true, get: function () { return ExceptionEntity_1.shouldReportException; } });
|
|
16
|
-
// =============================================================================
|
|
17
|
-
// INFRASTRUCTURE LAYER EXPORTS
|
|
18
|
-
// =============================================================================
|
|
19
|
-
// State Store (Zustand)
|
|
20
|
-
var ExceptionStore_1 = require("./infrastructure/storage/ExceptionStore");
|
|
21
|
-
Object.defineProperty(exports, "useExceptionStore", { enumerable: true, get: function () { return ExceptionStore_1.useExceptionStore; } });
|
|
22
|
-
Object.defineProperty(exports, "useExceptions", { enumerable: true, get: function () { return ExceptionStore_1.useExceptions; } });
|
|
23
|
-
// Services
|
|
24
|
-
var ExceptionService_1 = require("./infrastructure/services/ExceptionService");
|
|
25
|
-
Object.defineProperty(exports, "ExceptionService", { enumerable: true, get: function () { return ExceptionService_1.ExceptionService; } });
|
|
26
|
-
Object.defineProperty(exports, "exceptionService", { enumerable: true, get: function () { return ExceptionService_1.exceptionService; } });
|
|
27
|
-
// =============================================================================
|
|
28
|
-
// PRESENTATION LAYER EXPORTS
|
|
29
|
-
// =============================================================================
|
|
30
|
-
// Components
|
|
31
|
-
var ErrorBoundary_1 = require("./presentation/components/ErrorBoundary");
|
|
32
|
-
Object.defineProperty(exports, "ErrorBoundary", { enumerable: true, get: function () { return ErrorBoundary_1.ErrorBoundary; } });
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Exception Service - Infrastructure Layer
|
|
3
|
-
* Centralized exception handling and reporting
|
|
4
|
-
*/
|
|
5
|
-
import type { ExceptionContext, ExceptionSeverity, ExceptionCategory } from '../../domain/entities/ExceptionEntity';
|
|
6
|
-
export declare class ExceptionService {
|
|
7
|
-
private static instance;
|
|
8
|
-
private constructor();
|
|
9
|
-
static getInstance(): ExceptionService;
|
|
10
|
-
/**
|
|
11
|
-
* Handle an exception
|
|
12
|
-
*/
|
|
13
|
-
handleException(error: Error, severity?: ExceptionSeverity, category?: ExceptionCategory, context?: ExceptionContext): void;
|
|
14
|
-
/**
|
|
15
|
-
* Report exception to external service (e.g., Sentry)
|
|
16
|
-
*/
|
|
17
|
-
private reportException;
|
|
18
|
-
/**
|
|
19
|
-
* Handle network errors
|
|
20
|
-
*/
|
|
21
|
-
handleNetworkError(error: Error, context?: ExceptionContext): void;
|
|
22
|
-
/**
|
|
23
|
-
* Handle validation errors
|
|
24
|
-
*/
|
|
25
|
-
handleValidationError(error: Error, context?: ExceptionContext): void;
|
|
26
|
-
/**
|
|
27
|
-
* Handle storage/permission errors
|
|
28
|
-
*/
|
|
29
|
-
handleStorageError(error: Error, context?: ExceptionContext): void;
|
|
30
|
-
/**
|
|
31
|
-
* Handle fatal errors
|
|
32
|
-
*/
|
|
33
|
-
handleFatalError(error: Error, context?: ExceptionContext): void;
|
|
34
|
-
/**
|
|
35
|
-
* Clear all exceptions
|
|
36
|
-
*/
|
|
37
|
-
clearExceptions(): void;
|
|
38
|
-
}
|
|
39
|
-
export declare const exceptionService: ExceptionService;
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Exception Service - Infrastructure Layer
|
|
4
|
-
* Centralized exception handling and reporting
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.exceptionService = exports.ExceptionService = void 0;
|
|
8
|
-
const ExceptionEntity_1 = require("../../domain/entities/ExceptionEntity");
|
|
9
|
-
const ExceptionStore_1 = require("../storage/ExceptionStore");
|
|
10
|
-
class ExceptionService {
|
|
11
|
-
constructor() { }
|
|
12
|
-
static getInstance() {
|
|
13
|
-
if (!ExceptionService.instance) {
|
|
14
|
-
ExceptionService.instance = new ExceptionService();
|
|
15
|
-
}
|
|
16
|
-
return ExceptionService.instance;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Handle an exception
|
|
20
|
-
*/
|
|
21
|
-
handleException(error, severity = 'error', category = 'unknown', context = {}) {
|
|
22
|
-
const exception = (0, ExceptionEntity_1.createException)(error, severity, category, context);
|
|
23
|
-
// Add to store
|
|
24
|
-
ExceptionStore_1.useExceptionStore.getState().addException(exception);
|
|
25
|
-
// Report to external service if needed
|
|
26
|
-
if ((0, ExceptionEntity_1.shouldReportException)(exception)) {
|
|
27
|
-
this.reportException(exception);
|
|
28
|
-
}
|
|
29
|
-
// Mark as handled
|
|
30
|
-
ExceptionStore_1.useExceptionStore.getState().markAsHandled(exception.id);
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Report exception to external service (e.g., Sentry)
|
|
34
|
-
*/
|
|
35
|
-
async reportException(exception) {
|
|
36
|
-
try {
|
|
37
|
-
// Mark as reported
|
|
38
|
-
ExceptionStore_1.useExceptionStore.getState().markAsReported(exception.id);
|
|
39
|
-
}
|
|
40
|
-
catch (error) {
|
|
41
|
-
// Silent failure
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Handle network errors
|
|
46
|
-
*/
|
|
47
|
-
handleNetworkError(error, context = {}) {
|
|
48
|
-
this.handleException(error, 'error', 'network', context);
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Handle validation errors
|
|
52
|
-
*/
|
|
53
|
-
handleValidationError(error, context = {}) {
|
|
54
|
-
this.handleException(error, 'warning', 'validation', context);
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Handle storage/permission errors
|
|
58
|
-
*/
|
|
59
|
-
handleStorageError(error, context = {}) {
|
|
60
|
-
this.handleException(error, 'error', 'storage', context);
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Handle fatal errors
|
|
64
|
-
*/
|
|
65
|
-
handleFatalError(error, context = {}) {
|
|
66
|
-
this.handleException(error, 'fatal', 'system', context);
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Clear all exceptions
|
|
70
|
-
*/
|
|
71
|
-
clearExceptions() {
|
|
72
|
-
ExceptionStore_1.useExceptionStore.getState().clearExceptions();
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
exports.ExceptionService = ExceptionService;
|
|
76
|
-
exports.exceptionService = ExceptionService.getInstance();
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Exception Store - Zustand State Management
|
|
3
|
-
* Global exception tracking and error state
|
|
4
|
-
*/
|
|
5
|
-
import type { ExceptionEntity } from '../../domain/entities/ExceptionEntity';
|
|
6
|
-
interface ExceptionStore {
|
|
7
|
-
exceptions: ExceptionEntity[];
|
|
8
|
-
lastError: ExceptionEntity | null;
|
|
9
|
-
errorCount: number;
|
|
10
|
-
addException: (exception: ExceptionEntity) => void;
|
|
11
|
-
markAsHandled: (exceptionId: string) => void;
|
|
12
|
-
markAsReported: (exceptionId: string) => void;
|
|
13
|
-
clearExceptions: () => void;
|
|
14
|
-
getExceptionsByCategory: (category: string) => ExceptionEntity[];
|
|
15
|
-
getUnhandledExceptions: () => ExceptionEntity[];
|
|
16
|
-
}
|
|
17
|
-
export declare const useExceptionStore: import("zustand").UseBoundStore<import("zustand").StoreApi<ExceptionStore>>;
|
|
18
|
-
/**
|
|
19
|
-
* Hook for accessing exception state
|
|
20
|
-
*/
|
|
21
|
-
export declare const useExceptions: () => {
|
|
22
|
-
exceptions: ExceptionEntity[];
|
|
23
|
-
lastError: ExceptionEntity | null;
|
|
24
|
-
errorCount: number;
|
|
25
|
-
addException: (exception: ExceptionEntity) => void;
|
|
26
|
-
markAsHandled: (exceptionId: string) => void;
|
|
27
|
-
markAsReported: (exceptionId: string) => void;
|
|
28
|
-
clearExceptions: () => void;
|
|
29
|
-
getExceptionsByCategory: (category: string) => ExceptionEntity[];
|
|
30
|
-
getUnhandledExceptions: () => ExceptionEntity[];
|
|
31
|
-
};
|
|
32
|
-
export {};
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Exception Store - Zustand State Management
|
|
4
|
-
* Global exception tracking and error state
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.useExceptions = exports.useExceptionStore = void 0;
|
|
8
|
-
const zustand_1 = require("zustand");
|
|
9
|
-
exports.useExceptionStore = (0, zustand_1.create)((set, get) => ({
|
|
10
|
-
exceptions: [],
|
|
11
|
-
lastError: null,
|
|
12
|
-
errorCount: 0,
|
|
13
|
-
addException: (exception) => {
|
|
14
|
-
const { exceptions } = get();
|
|
15
|
-
set({
|
|
16
|
-
exceptions: [exception, ...exceptions].slice(0, 100), // Keep last 100
|
|
17
|
-
lastError: exception,
|
|
18
|
-
errorCount: get().errorCount + 1,
|
|
19
|
-
});
|
|
20
|
-
},
|
|
21
|
-
markAsHandled: (exceptionId) => {
|
|
22
|
-
const { exceptions } = get();
|
|
23
|
-
const updated = exceptions.map((ex) => ex.id === exceptionId ? { ...ex, handled: true } : ex);
|
|
24
|
-
set({ exceptions: updated });
|
|
25
|
-
},
|
|
26
|
-
markAsReported: (exceptionId) => {
|
|
27
|
-
const { exceptions } = get();
|
|
28
|
-
const updated = exceptions.map((ex) => ex.id === exceptionId ? { ...ex, reported: true } : ex);
|
|
29
|
-
set({ exceptions: updated });
|
|
30
|
-
},
|
|
31
|
-
clearExceptions: () => set({ exceptions: [], lastError: null }),
|
|
32
|
-
getExceptionsByCategory: (category) => {
|
|
33
|
-
const { exceptions } = get();
|
|
34
|
-
return exceptions.filter((ex) => ex.category === category);
|
|
35
|
-
},
|
|
36
|
-
getUnhandledExceptions: () => {
|
|
37
|
-
const { exceptions } = get();
|
|
38
|
-
return exceptions.filter((ex) => !ex.handled);
|
|
39
|
-
},
|
|
40
|
-
}));
|
|
41
|
-
/**
|
|
42
|
-
* Hook for accessing exception state
|
|
43
|
-
*/
|
|
44
|
-
const useExceptions = () => {
|
|
45
|
-
const { exceptions, lastError, errorCount, addException, markAsHandled, markAsReported, clearExceptions, getExceptionsByCategory, getUnhandledExceptions, } = (0, exports.useExceptionStore)();
|
|
46
|
-
return {
|
|
47
|
-
exceptions,
|
|
48
|
-
lastError,
|
|
49
|
-
errorCount,
|
|
50
|
-
addException,
|
|
51
|
-
markAsHandled,
|
|
52
|
-
markAsReported,
|
|
53
|
-
clearExceptions,
|
|
54
|
-
getExceptionsByCategory,
|
|
55
|
-
getUnhandledExceptions,
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
exports.useExceptions = useExceptions;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Error Boundary Component
|
|
3
|
-
* Catches React errors and provides fallback UI
|
|
4
|
-
*/
|
|
5
|
-
import React, { Component, ReactNode } from 'react';
|
|
6
|
-
interface Props {
|
|
7
|
-
children: ReactNode;
|
|
8
|
-
fallback?: ReactNode;
|
|
9
|
-
}
|
|
10
|
-
interface State {
|
|
11
|
-
hasError: boolean;
|
|
12
|
-
error: Error | null;
|
|
13
|
-
}
|
|
14
|
-
export declare class ErrorBoundary extends Component<Props, State> {
|
|
15
|
-
constructor(props: Props);
|
|
16
|
-
static getDerivedStateFromError(error: Error): State;
|
|
17
|
-
componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void;
|
|
18
|
-
handleReset: () => void;
|
|
19
|
-
render(): ReactNode;
|
|
20
|
-
}
|
|
21
|
-
export {};
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Error Boundary Component
|
|
4
|
-
* Catches React errors and provides fallback UI
|
|
5
|
-
*/
|
|
6
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
-
if (k2 === undefined) k2 = k;
|
|
8
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
-
}
|
|
12
|
-
Object.defineProperty(o, k2, desc);
|
|
13
|
-
}) : (function(o, m, k, k2) {
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
o[k2] = m[k];
|
|
16
|
-
}));
|
|
17
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
-
}) : function(o, v) {
|
|
20
|
-
o["default"] = v;
|
|
21
|
-
});
|
|
22
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
-
var ownKeys = function(o) {
|
|
24
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
-
var ar = [];
|
|
26
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
-
return ar;
|
|
28
|
-
};
|
|
29
|
-
return ownKeys(o);
|
|
30
|
-
};
|
|
31
|
-
return function (mod) {
|
|
32
|
-
if (mod && mod.__esModule) return mod;
|
|
33
|
-
var result = {};
|
|
34
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
-
__setModuleDefault(result, mod);
|
|
36
|
-
return result;
|
|
37
|
-
};
|
|
38
|
-
})();
|
|
39
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
exports.ErrorBoundary = void 0;
|
|
41
|
-
const react_1 = __importStar(require("react"));
|
|
42
|
-
const react_native_1 = require("react-native");
|
|
43
|
-
const ExceptionService_1 = require("../../infrastructure/services/ExceptionService");
|
|
44
|
-
const react_native_design_system_1 = require("@umituz/react-native-design-system");
|
|
45
|
-
class ErrorBoundary extends react_1.Component {
|
|
46
|
-
constructor(props) {
|
|
47
|
-
super(props);
|
|
48
|
-
this.handleReset = () => {
|
|
49
|
-
this.setState({
|
|
50
|
-
hasError: false,
|
|
51
|
-
error: null,
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
|
-
this.state = {
|
|
55
|
-
hasError: false,
|
|
56
|
-
error: null,
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
static getDerivedStateFromError(error) {
|
|
60
|
-
return {
|
|
61
|
-
hasError: true,
|
|
62
|
-
error,
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
componentDidCatch(error, errorInfo) {
|
|
66
|
-
// Log error to exception service
|
|
67
|
-
ExceptionService_1.exceptionService.handleFatalError(error, {
|
|
68
|
-
componentStack: errorInfo.componentStack ?? undefined,
|
|
69
|
-
screen: 'ErrorBoundary',
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
render() {
|
|
73
|
-
if (this.state.hasError) {
|
|
74
|
-
if (this.props.fallback) {
|
|
75
|
-
return this.props.fallback;
|
|
76
|
-
}
|
|
77
|
-
return (<ErrorDisplay error={this.state.error} onReset={this.handleReset}/>);
|
|
78
|
-
}
|
|
79
|
-
return this.props.children;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
exports.ErrorBoundary = ErrorBoundary;
|
|
83
|
-
const ErrorDisplay = ({ error, onReset }) => {
|
|
84
|
-
const tokens = (0, react_native_design_system_1.useAppDesignTokens)();
|
|
85
|
-
const styles = getStyles(tokens);
|
|
86
|
-
return (<react_native_1.View style={styles.container}>
|
|
87
|
-
<react_native_1.Text style={styles.title}>Something went wrong</react_native_1.Text>
|
|
88
|
-
<react_native_1.Text style={styles.message}>
|
|
89
|
-
{error?.message || 'An unexpected error occurred'}
|
|
90
|
-
</react_native_1.Text>
|
|
91
|
-
<react_native_1.TouchableOpacity style={styles.button} onPress={onReset}>
|
|
92
|
-
<react_native_1.Text style={styles.buttonText}>Try Again</react_native_1.Text>
|
|
93
|
-
</react_native_1.TouchableOpacity>
|
|
94
|
-
</react_native_1.View>);
|
|
95
|
-
};
|
|
96
|
-
const getStyles = (tokens) => react_native_1.StyleSheet.create({
|
|
97
|
-
container: {
|
|
98
|
-
flex: 1,
|
|
99
|
-
justifyContent: 'center',
|
|
100
|
-
alignItems: 'center',
|
|
101
|
-
padding: tokens.spacing.lg,
|
|
102
|
-
backgroundColor: tokens.colors.backgroundPrimary,
|
|
103
|
-
},
|
|
104
|
-
title: {
|
|
105
|
-
fontSize: tokens.typography.headlineSmall.fontSize,
|
|
106
|
-
fontWeight: tokens.typography.headlineSmall.fontWeight,
|
|
107
|
-
marginBottom: tokens.spacing.sm,
|
|
108
|
-
color: tokens.colors.textPrimary,
|
|
109
|
-
},
|
|
110
|
-
message: {
|
|
111
|
-
fontSize: tokens.typography.bodyLarge.fontSize,
|
|
112
|
-
color: tokens.colors.textSecondary,
|
|
113
|
-
textAlign: 'center',
|
|
114
|
-
marginBottom: tokens.spacing.lg,
|
|
115
|
-
},
|
|
116
|
-
button: {
|
|
117
|
-
backgroundColor: tokens.colors.primary,
|
|
118
|
-
paddingHorizontal: tokens.spacing.lg,
|
|
119
|
-
paddingVertical: tokens.spacing.sm,
|
|
120
|
-
borderRadius: tokens.borders.radius.sm,
|
|
121
|
-
},
|
|
122
|
-
buttonText: {
|
|
123
|
-
color: tokens.colors.textInverse,
|
|
124
|
-
fontSize: tokens.typography.bodyLarge.fontSize,
|
|
125
|
-
fontWeight: tokens.typography.labelLarge.fontWeight,
|
|
126
|
-
},
|
|
127
|
-
});
|