Skip to content

Commit 1c9afa5

Browse files
committed
remove comments
1 parent 3047620 commit 1c9afa5

File tree

1 file changed

+1
-18
lines changed

1 file changed

+1
-18
lines changed

lib/index.js

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -116,31 +116,19 @@ async function register (server, options) {
116116
}
117117

118118
const config = Object.assign({}, defaults, options)
119+
config.links = Array.isArray(config.links) ? config.links : [config.links]
119120

120-
/**
121-
* Cut early if `showErrors` is false. No need to
122-
* hook the extension point in production.
123-
*/
124121
if (!config.showErrors) {
125122
return
126123
}
127124

128-
// require `vision` plugin in case the user provides an error template
129125
if (config.template) {
130126
server.dependency(['vision'])
131127
}
132128

133-
// Make sure the `links` are an array
134-
if (!Array.isArray(config.links)) {
135-
config.links = [config.links]
136-
}
137-
138-
// extend the request lifecycle at `onPreResponse`
139-
// to change the default error handling behavior (if enabled)
140129
server.ext('onPreResponse', async (request, h) => {
141130
const error = request.response
142131

143-
// only show `bad implementation` developer errors (status code 500)
144132
if (error.isBoom && error.output.statusCode === 500) {
145133
const accept = request.raw.req.headers.accept
146134
const agent = request.raw.req.headers['user-agent']
@@ -165,9 +153,6 @@ async function register (server, options) {
165153
console.log(ForTerminal(json))
166154
}
167155

168-
// take priority:
169-
// - check "agent" header for REST request (cURL, Postman & Co.)
170-
// - check "accept" header for JSON request
171156
if (wantsJson({ accept, agent })) {
172157
const details = Object.assign({}, errorResponse, {
173158
stacktrace: errorResponse.stacktrace.split('\n').map(line => line.trim())
@@ -187,7 +172,6 @@ async function register (server, options) {
187172
.code(statusCode)
188173
}
189174

190-
// render Youch HTML template
191175
const html = await youch.toHTML()
192176

193177
return h
@@ -196,7 +180,6 @@ async function register (server, options) {
196180
.code(statusCode)
197181
}
198182

199-
// no developer error, go ahead with the response
200183
return h.continue
201184
})
202185
}

0 commit comments

Comments
 (0)