Skip to content

Commit 795d382

Browse files
committed
fix: fixed app.emit
1 parent 2617011 commit 795d382

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

index.js

+3-12
Original file line numberDiff line numberDiff line change
@@ -129,19 +129,12 @@ function errorHandler(
129129
try {
130130
if (!err) return;
131131

132+
this.app.emit('error', err, this);
133+
132134
// nothing we can do here other
133135
// than delegate to the app-level
134136
// handler and log.
135-
if (this.headerSent || !this.writable) {
136-
err.headerSent = true;
137-
this.app.emit('error', err, this);
138-
this.app.emit(
139-
'error',
140-
new Error('Headers were already sent, returning early'),
141-
this
142-
);
143-
return;
144-
}
137+
if (this.headerSent || !this.writable) return;
145138

146139
// translate messages
147140
const translate = (message) =>
@@ -243,8 +236,6 @@ function errorHandler(
243236
if (_isObject(err.headers) && Object.keys(err.headers).length > 0)
244237
this.set(err.headers);
245238

246-
this.app.emit('error', err, this);
247-
248239
// fix page title and description
249240
const meta = {
250241
title: this.body.error,

0 commit comments

Comments
 (0)