File tree Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -187,11 +187,10 @@ function errorHandler(
187187 this . app . emit ( 'error' , err , this ) ;
188188
189189 // fix page title and description
190- if ( ! this . api ) {
191- this . state . meta = this . state . meta || { } ;
192- this . state . meta . title = this . body . error ;
193- this . state . meta . description = err . message ;
194- }
190+ const meta = {
191+ title : this . body . error ,
192+ description : err . message
193+ } ;
195194
196195 switch ( type ) {
197196 case 'html' :
@@ -202,7 +201,7 @@ function errorHandler(
202201 // https://github.com/koajs/koa/issues/646
203202 if ( hasRender ) {
204203 try {
205- await this . render ( '404' ) ;
204+ await this . render ( '404' , { meta } ) ;
206205 } catch ( err_ ) {
207206 logger . error ( err_ ) ;
208207 this . body = _404 ;
@@ -221,7 +220,7 @@ function errorHandler(
221220 // render the 5xx page
222221 if ( hasRender ) {
223222 try {
224- await this . render ( '500' ) ;
223+ await this . render ( '500' , { meta } ) ;
225224 } catch ( err_ ) {
226225 logger . error ( err_ ) ;
227226 this . body = _500 ;
You can’t perform that action at this time.
0 commit comments