Skip to content

Commit e7e0b2c

Browse files
committed
changleog and readme updated before publishing version 1.1.2
1 parent b32e602 commit e7e0b2c

File tree

7 files changed

+45
-27
lines changed

7 files changed

+45
-27
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@
33
All notable changes to this project will be documented in this file.
44
This project adheres to [Semantic Versioning](https://semver.org) and follows [Conventional Commits](https://www.conventionalcommits.org).
55

6+
---
7+
8+
## [1.1.2](https://github.com/dev-rashedin/express-error-toolkit/releases/tag/1.1.2) – 2025-07-19
9+
10+
### ✨ Improvements
11+
12+
- Introduced `introLine` to enhance developer experience (DX) when logging errors
13+
- Made `introLine` fully customizable through `setErrorOptions()` or by setting it to `false` to disable it
14+
15+
616
---
717

818
## [1.1.1](https://github.com/dev-rashedin/express-error-toolkit/releases/tag/1.1.1) – 2025-07-19

README.md

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,19 +134,39 @@ In production (`NODE_ENV=production`), both are automatically suppressed for saf
134134

135135
### 5. 🖍️ Readable Console Logs with ANSI Colors
136136

137-
To enhance developer experience during debugging, this toolkit uses **ANSI escape codes** to style console logs **no external dependencies** like `chalk`.
137+
To enhance developer experience during debugging, this toolkit uses **ANSI escape codes****no external dependencies like `chalk` required** — to make console logs more readable.
138138

139-
Each part of the error log is color-coded using a traffic light scheme:
139+
Each part of the error log is styled using a traffic light-inspired color scheme:
140140

141-
- 🔴 **Error Message** – Red
141+
- 🔴 **Error Status & Message** – Red
142142
- 🟡 **Error Details** – Yellow
143143
- 🟢 **Stack Trace** – Green
144144

145-
> Here's an example of how your console might look in development:
145+
> 🖼️ Example: Here's how the console might look in development mode:
146146
147-
![Colored error output preview](./assets/console-preview-1.1.1.png)
147+
![Colored error output preview](./assets/console-preview-1.1.2.png)
148148

149-
If needed, you can disable this output using either `.env` or `setErrorOptions()`:
149+
---
150+
151+
#### ✨ Customizing the Intro Line
152+
153+
By default, an introductory line (*"Even the best code breaks sometimes! Let's debug..."*) is displayed before each error block.
154+
155+
You can control this with the `introLine` option:
156+
157+
```ts
158+
import { setErrorOptions } from 'express-error-toolkit';
159+
160+
// Disable the intro line
161+
setErrorOptions({
162+
introLine: false
163+
});
164+
165+
// Customize the intro line
166+
setErrorOptions({
167+
introLine: '🚨 Debugging session begins here...'
168+
});
169+
```
150170

151171
---
152172

assets/console-preview-1.1.2.png

73.6 KB
Loading

src/global-error-handler.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
dimGray,
1313
bold,
1414
} from './utils/console-colors';
15-
import { centerText } from './utils';
1615
import { ErrorOptions, ErrorResponse } from './types';
1716

1817

@@ -74,25 +73,24 @@ export const globalErrorHandler = (
7473

7574
// Log the error if configured to do so
7675
if (errorOptions.logError) {
77-
76+
77+
// log the intro line if it's true
7878
if (errorOptions.introLine) {
7979
console.error(`\n${(bold(`${errorOptions.introLine}`))}\n`);
80+
} else {
81+
console.error();
8082
}
8183

8284
// log the error status
8385
console.error(
84-
`${boldRed('🔴 Error Status:')} ${red(String(errorResponse.status))}`
86+
`${boldRed('🔴 Error Status:')} ${red(String(errorResponse.status))}\n`
8587
);
8688

87-
console.error(); // empty line for better readability
88-
8989
// log the error message
9090
console.error(
91-
`${boldRed('🔴 Error Message:')} ${red(errorResponse.message)}`
91+
`${boldRed('🔴 Error Message:')} ${red(errorResponse.message)}\n`
9292
);
9393

94-
console.error(); // empty line for better readability
95-
9694
// Log error details if available
9795
if (errorResponse.errorDetails) {
9896
console.error(boldYellow('🟡 Error Details:'));
@@ -103,10 +101,9 @@ export const globalErrorHandler = (
103101
: errorResponse.errorDetails
104102
)
105103
);
104+
console.error();
106105
}
107106

108-
console.error(); // empty line for better readability
109-
110107
// Log stack trace if available
111108
if (errorResponse.stack) {
112109
const stackLines = errorResponse.stack as string[];

src/not-found-handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { NotFoundError } from './error';
55

66
export const notFoundHandler = (
77
req: Request,
8-
res: Response,
8+
_res: Response,
99
next: NextFunction
1010
) => {
1111
const method = req.method || 'UNKNOWN_METHOD';

src/utils/console-colors.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const colors = {
55
green: '\x1b[32m',
66
yellow: '\x1b[33m',
77
dimGray: '\x1b[2m',
8-
underline: '\x1b[4m',
98
};
109

1110
export function boldRed(text: string) : string {
@@ -32,11 +31,10 @@ export function green(text: string) : string {
3231
return `${colors.green}${text}${colors.reset}`;
3332
}
3433

35-
3634
export function bold (text: string) : string {
3735
return `${colors.bold}${text}${colors.reset}`;
3836
}
3937

4038
export function dimGray(text: string) : string {
41-
return `${colors.dimGray}${colors.underline}${text}${colors.reset}`;
39+
return `${colors.dimGray}${text}${colors.reset}`;
4240
}

src/utils/index.ts

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)