update error

This commit is contained in:
Pooya Parsa 2017-08-05 23:50:26 +04:30
parent c5578f8822
commit 9bb7d0331a
4 changed files with 8 additions and 12 deletions

View File

@ -31,7 +31,7 @@ export default {
props: ['error'],
head () {
return {
title: this.error ? ((this.error.statusCode || 500) + ' - ' + (this.error.message || 'Error')) : '500 - Error',
title: this.error ? ((this.error.statusCode || 500) + ' - ' + (this.error.message || 'Nuxt Server Error')) : '500 - Nuxt Server Error',
link: [
{ rel: 'stylesheet', href: 'https://cdnjs.cloudflare.com/ajax/libs/normalize/7.0.0/normalize.min.css', type: 'text/css', media: 'all' },
{ rel: 'stylesheet', href: 'https://cdnjs.cloudflare.com/ajax/libs/milligram/1.3.0/milligram.min.css', type: 'text/css', media: 'all' }
@ -64,6 +64,7 @@ export default {
.__nuxt-error-page .error-box {
box-shadow: 0px 0px 9px #d3d3d3;
padding: 10px;
text-align: left;
}
.__nuxt-error-page .poweredby {
text-align: center;

View File

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>{{ status }} - {{ name }}</title>
<title>{{ status }} - {{ message }}</title>
<style>
/*! normalize.css v7.0.0 | MIT License | github.com/necolas/normalize.css */html{line-height:1.15;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,footer,header,nav,section{display:block}h1{font-size:2em;margin:.67em 0}figcaption,figure,main{display:block}figure{margin:1em 40px}hr{box-sizing:content-box;height:0;overflow:visible}pre{font-family:monospace,monospace;font-size:1em}a{background-color:transparent;-webkit-text-decoration-skip:objects}abbr[title]{border-bottom:none;text-decoration:underline;text-decoration:underline dotted}b,strong{font-weight:inherit}b,strong{font-weight:bolder}code,kbd,samp{font-family:monospace,monospace;font-size:1em}dfn{font-style:italic}mark{background-color:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}audio,video{display:inline-block}audio:not([controls]){display:none;height:0}img{border-style:none}svg:not(:root){overflow:hidden}button,input,optgroup,select,textarea{font-family:sans-serif;font-size:100%;line-height:1.15;margin:0}button,input{overflow:visible}button,select{text-transform:none}[type=reset],[type=submit],button,html [type=button]{-webkit-appearance:button}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{border-style:none;padding:0}[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring,button:-moz-focusring{outline:1px dotted ButtonText}fieldset{padding:.35em .75em .625em}legend{box-sizing:border-box;color:inherit;display:table;max-width:100%;padding:0;white-space:normal}progress{display:inline-block;vertical-align:baseline}textarea{overflow:auto}[type=checkbox],[type=radio]{box-sizing:border-box;padding:0}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}[type=search]::-webkit-search-cancel-button,[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}details,menu{display:block}summary{display:list-item}canvas{display:inline-block}template{display:none}[hidden]{display:none}/*# sourceMappingURL=normalize.min.css.map */
</style>
@ -36,10 +36,6 @@
margin: 0 auto;
max-width: 70%;
}
.__nuxt-error-page .error-box {
box-shadow: 0px 0px 9px #d3d3d3;
padding: 10px;
}
.__nuxt-error-page .poweredby {
text-align: center;
margin-top: 10%;
@ -58,9 +54,8 @@ pre {
<div class="row">
<div class="column">
<h1>{{ status }} </h1>
<h4> {{ name }} </h4>
<%if(debug){%><pre class="error-box"><code>{{ message }}</code></pre><%}%>
<h1>{{ status }}</h1>
<h4>{{ message }}</h4>
</div>
</div>

View File

@ -281,12 +281,12 @@ export default class Renderer extends Tapable {
// ensure statusCode, message and name fields
err.statusCode = err.statusCode || 500
err.message = err.message || 'Nuxt Server Error'
err.name = (!err.name || err.name === 'Error') ? 'Nuxt Server Error' : err.name
err.name = (!err.name || err.name === 'Error') ? 'NuxtServerError' : err.name
const sendResponse = (content, type = 'text/html') => {
// Set Headers
res.statusCode = err.statusCode
res.statusMessage = err.name
res.statusMessage = this.options.render.debug ? err.message : err.name
res.setHeader('Content-Type', type + '; charset=utf-8')
res.setHeader('Content-Length', Buffer.byteLength(content))

View File

@ -35,7 +35,7 @@ test('/404 should display an error too', async t => {
test('/ with renderAndGetWindow()', async t => {
const err = await t.throws(nuxt.renderAndGetWindow(url('/')))
t.is(err.response.statusCode, 500)
t.is(err.response.statusMessage, 'Nuxt Server Error')
t.is(err.response.statusMessage, 'NuxtServerError')
})
// Close server and ask nuxt to stop listening to file changes