Skip to content

Commit

Permalink
fix: don't log 404
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Nov 19, 2020
1 parent 7a2c185 commit 541ede0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ export function defaultContentType (res: ServerResponse, type: string) {
}

export function error (res: ServerResponse, error: Error | string, debug?: boolean, code?: number) {
res.statusCode = code || (res.statusCode !== 200)
code = code || (res.statusCode !== 200)
? res.statusCode
// @ts-ignore
: (error.status || error.statusCode || 500)

if (debug) {
if (debug && code !== 404) {
console.error(error) // eslint-disable-line no-console
}

res.end(`"Internal Error (${res.statusCode})"`)
res.end(`"Internal Error (${code})"`)
}

export function redirect (res: ServerResponse, location: string, code = 302) {
Expand Down

0 comments on commit 541ede0

Please sign in to comment.