File tree Expand file tree Collapse file tree 3 files changed +16
-11
lines changed Expand file tree Collapse file tree 3 files changed +16
-11
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,15 @@ This project adheres to [Semantic Versioning](https://semver.org) and follows [C
55
66---
77
8+ ## [ 1.0.1] ( https://github.com/Rashedin-063/express-error-toolkit/releases/tag/1.0.1 ) – 2025-07-09
9+
10+ ### ✨ Improvements
11+
12+ - Added support for optional stack trace and error logging in ` globalErrorHandler `
13+ - Users can now control behavior using ` .env ` (` SHOW_STACK ` , ` LOG_ERROR ` ) or programmatically via ` setToolkitOptions() `
14+
15+ ---
16+
817## [ 1.0.0] ( https://github.com/Rashedin-063/express-error-toolkit/releases/tag/1.0.0 ) – 2025-07-07
918
1019### ✨ Features
Original file line number Diff line number Diff line change @@ -126,20 +126,20 @@ import { globalErrorHandler } from 'express-error-toolkit';
126126app .use (globalErrorHandler );
127127```
128128
129- By default, it includes stack trace in development (` NODE_ENV=development ` ).
130-
129+ By default, it includes stack trace and logs the error in development (` NODE_ENV=development ` ).
131130
132131---
133132
134133### 5. ** Set Options Globally (Optional)**
135134
136- You can configure the toolkit behavior (e.g., hide stack traces even in dev ):
135+ You can configure the toolkit behavior (e.g., hide stack traces and disable console logging even in development ):
137136
138137``` ts
139138import { setToolkitOptions } from ' express-error-toolkit' ;
140139
141140setToolkitOptions ({
142141 showStack: false ,
142+ logError: false
143143});
144144```
145145
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import { CustomAPIError } from './error';
66// Internal config object (optional override)
77let errorOptions = {
88 showStack : process . env . SHOW_STACK !== 'false' ,
9+ logError : process . env . LOG_ERROR !== 'false' ,
910} ;
1011
1112export function setErrorOptions (
@@ -36,8 +37,8 @@ export const globalErrorHandler = (
3637 let errorDetails : string | object | null | undefined ;
3738 let stack : string | undefined ;
3839
40+
3941 const isDev = process . env . NODE_ENV ?. trim ( ) === 'development' ;
40- const showStack = process . env . SHOW_STACK !== 'false' ;
4142
4243 if ( err instanceof Error ) {
4344 if ( isCustomAPIError ( err ) ) {
@@ -60,16 +61,11 @@ export const globalErrorHandler = (
6061 errorResponse . errorDetails = errorDetails ;
6162 }
6263
63- // if (process.env.NODE_ENV === 'development' && stack) {
64- // errorResponse.stack = stack;
65- // }
66-
67-
68- if ( isDev && stack && showStack ) {
64+ if ( isDev && stack && errorOptions . showStack ) {
6965 errorResponse . stack = stack . split ( '\n' ) . map ( ( line ) => line . trim ( ) ) ; ;
7066 }
7167
72- if ( process . env . NODE_ENV === 'development' ) {
68+ if ( isDev && errorOptions . logError ) {
7369 console . error ( err ) ;
7470 }
7571
You can’t perform that action at this time.
0 commit comments