1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00
next.js/pages/_error-debug.js
2016-10-25 17:16:54 +09:00

57 lines
1.1 KiB
JavaScript

import React from 'react'
import stripAnsi from 'strip-ansi'
import Head from 'next/head'
import style from 'next/css'
export default class ErrorDebug extends React.Component {
static getInitialProps ({ err }) {
const { message, module } = err
return { message, path: module.rawRequest }
}
render () {
const { message, path } = this.props
return <div className={styles.errorDebug}>
<Head>
<style dangerouslySetInnerHTML={{ __html: `
body {
background: #dc0067;
margin: 0;
}
`}} />
</Head>
<div className={styles.heading}>Error in {path}</div>
<pre className={styles.message}>{stripAnsi(message)}</pre>
</div>
}
}
const styles = {
body: style({
background: '#dc0067',
margin: 0
}),
errorDebug: style({
height: '100%',
padding: '16px',
boxSizing: 'border-box'
}),
message: style({
fontFamily: 'menlo-regular',
fontSize: '10px',
color: '#fff',
margin: 0
}),
heading: style({
fontFamily: 'sans-serif',
fontSize: '13px',
fontWeight: 'bold',
color: '#ff90c6',
marginBottom: '20px'
})
}