@kaliber/build 0.0.152-beta.2 → 0.0.152-beta.3
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/serve.js +11 -4
- package/package.json +1 -1
package/lib/serve.js
CHANGED
@@ -66,9 +66,7 @@ app.use((err, req, res, next) => {
|
|
66
66
|
if (err.status && err.status >= 400 && err.status < 500)
|
67
67
|
return res.status(err.status).send()
|
68
68
|
|
69
|
-
|
70
|
-
if (reportError) reportError(err, req)
|
71
|
-
|
69
|
+
reportServerError(err, req)
|
72
70
|
serveInternalServerError(err, { req, res, next })
|
73
71
|
})
|
74
72
|
|
@@ -148,13 +146,17 @@ function serveIndexWithRouting(file, { req, res, next }) {
|
|
148
146
|
const html = renderTemplate(template, location, { data })
|
149
147
|
res.status(status).set(headers).send(html)
|
150
148
|
})
|
151
|
-
.catch(error =>
|
149
|
+
.catch(error => {
|
150
|
+
reportServerError(error, req)
|
151
|
+
serveInternalServerError(error, { req, res, next })
|
152
|
+
})
|
152
153
|
else {
|
153
154
|
try {
|
154
155
|
const { data, status, headers } = dataOrPromise
|
155
156
|
const html = renderTemplate(template, location, { data })
|
156
157
|
res.status(status).set(headers).send(html)
|
157
158
|
} catch (error) {
|
159
|
+
reportServerError(error, req)
|
158
160
|
serveInternalServerError(error, { req, res, next })
|
159
161
|
}
|
160
162
|
}
|
@@ -190,3 +192,8 @@ function serveInternalServerError(error, { res, req, next }) {
|
|
190
192
|
.catch(next)
|
191
193
|
} else response.send(`<pre><title style='display: block;'>${error.stack || error.toString()}</title><pre>`)
|
192
194
|
}
|
195
|
+
|
196
|
+
function reportServerError(error, req) {
|
197
|
+
console.error(error)
|
198
|
+
if (reportError) reportError(error, req)
|
199
|
+
}
|
package/package.json
CHANGED