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

57 lines
1.1 KiB
JavaScript
Raw Normal View History

2016-10-19 12:41:45 +00:00
import React from 'react'
import stripAnsi from 'strip-ansi'
import Head from 'next/head'
2016-10-25 08:16:54 +00:00
import style from 'next/css'
2016-10-19 12:41:45 +00:00
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}>
2016-10-19 12:41:45 +00:00
<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>
2016-10-19 12:41:45 +00:00
</div>
}
}
const styles = {
body: style({
2016-10-19 12:41:45 +00:00
background: '#dc0067',
margin: 0
}),
2016-10-19 12:41:45 +00:00
errorDebug: style({
2016-10-19 12:41:45 +00:00
height: '100%',
padding: '16px',
boxSizing: 'border-box'
}),
2016-10-19 12:41:45 +00:00
message: style({
2016-10-19 12:41:45 +00:00
fontFamily: 'menlo-regular',
fontSize: '10px',
color: '#fff',
margin: 0
}),
2016-10-19 12:41:45 +00:00
heading: style({
2016-10-19 12:41:45 +00:00
fontFamily: 'sans-serif',
fontSize: '13px',
fontWeight: 'bold',
color: '#ff90c6',
marginBottom: '20px'
})
}