Skip to content

Commit 3ac9e9a

Browse files
author
Danial Manavi
committed
feat: added normalize error object function
1 parent 1f11fbd commit 3ac9e9a

3 files changed

Lines changed: 9 additions & 1 deletion

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "error-lib",
3-
"version": "2.0.1",
3+
"version": "2.0.2",
44
"description": "Standard Error Library for JavaScript/TypeScript projects (NodeJS & Browsers)",
55
"type": "commonjs",
66
"files": [

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ export * from './forbidden_error';
44
export * from './not_found_error';
55
export * from './resource_not_found_error';
66
export * from './route_not_found_error';
7+
export * from './serializer';
78
export * from './validation_error';

src/serializer.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* Normalize error object to remove non-serializable properties
3+
* @param error Error object
4+
* @returns Normalized error object
5+
*/
6+
export const normalizeErrorObject = (error: Error): Error =>
7+
JSON.parse(JSON.stringify(error, Object.getOwnPropertyNames(error)));

0 commit comments

Comments
 (0)