index.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /**
  2. * React Static Boilerplate
  3. * https://github.com/koistya/react-static-boilerplate
  4. *
  5. * Copyright © 2015-2016 Konstantin Tarkus (@koistya)
  6. *
  7. * This source code is licensed under the MIT license found in the
  8. * LICENSE.txt file in the root directory of this source tree.
  9. */
  10. import React from 'react';
  11. import { Layout } from '../../components';
  12. function ErrorPage({ title, message, stackTrace }) {
  13. return (
  14. <Layout>
  15. <h1>{title}</h1>
  16. <p>{message}</p>
  17. {stackTrace && <pre>{stackTrace}</pre>}
  18. </Layout>
  19. );
  20. }
  21. ErrorPage.propTypes = {
  22. title: React.PropTypes.string.isRequired,
  23. message: React.PropTypes.string.isRequired,
  24. stackTrace: React.PropTypes.string.isRequired,
  25. };
  26. export default {
  27. path: '/error',
  28. action({ error = {} }) {
  29. const props = {
  30. title: 'Error',
  31. message: 'Oups, something went wrong!',
  32. stackTrace: process.env.NODE_ENV === 'production' ? null : error.stack,
  33. };
  34. if (error.status === 404) {
  35. props.title = 'Page Not Found';
  36. props.message = 'This page does not exist.';
  37. }
  38. return {
  39. title: props.title,
  40. component: ErrorPage,
  41. props,
  42. };
  43. },
  44. };