Skip to content

Commit

Permalink
chore: override meta with err meta created
Browse files Browse the repository at this point in the history
  • Loading branch information
titanism committed Jul 1, 2022
1 parent 265fc84 commit 449ba72
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,10 @@ function errorHandler(
this.app.emit('error', err, this);

// fix page title and description
if (!this.api) {
this.state.meta = this.state.meta || {};
this.state.meta.title = this.body.error;
this.state.meta.description = err.message;
}
const meta = {
title: this.body.error,
description: err.message
};

switch (type) {
case 'html':
Expand All @@ -202,7 +201,7 @@ function errorHandler(
// https://github.com/koajs/koa/issues/646
if (hasRender) {
try {
await this.render('404');
await this.render('404', { meta });
} catch (err_) {
logger.error(err_);
this.body = _404;
Expand All @@ -221,7 +220,7 @@ function errorHandler(
// render the 5xx page
if (hasRender) {
try {
await this.render('500');
await this.render('500', { meta });
} catch (err_) {
logger.error(err_);
this.body = _500;
Expand Down

0 comments on commit 449ba72

Please sign in to comment.