Skip to content

Commit

Permalink
Finish up making error reporting standard across different variations.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonesy committed Feb 11, 2020
1 parent e1af57b commit 751c8f5
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 13 deletions.
1 change: 1 addition & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ config/*.json
# Logs
logs
*.log
server/logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
Expand Down
12 changes: 6 additions & 6 deletions frontend/server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,14 @@ log.addLevel('debug', 2900, { fg: 'green' });
const memoryStore = new MemoryStore({
checkPeriod: 86400000, // prune expired entries every 24h
});
const logger = morgan('common', {
stream: fs.createWriteStream(path.join(__dirname, 'logs', 'frontend.log'), {
flags: 'a',
}),
});

if (process.env.NODE_ENV !== 'test') {
const logger = morgan('common', {
stream: fs.createWriteStream(path.join(__dirname, 'logs', 'frontend.log'), {
flags: 'a',
}),
});
app.use(logger);
app.use(morgan('dev'));
}

Expand Down Expand Up @@ -92,7 +93,6 @@ app.use(
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(express.static(path.join(__dirname, '..', 'dist')));
app.use(logger);

// Auth & Session
app.use(cookieParser(cookieSecret));
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/modules/app/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ export const toggleReportError = () => ({
type: 'app/report-error/toggle',
});

export const reportError = payload => ({
export const reportError = (payload, componentStack) => ({
type: 'user/report-error',
error: true,
meta: {
componentStack,
},
payload,
});

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/modules/app/components/report-error/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Textarea from '@atlaskit/textarea';

function ReportError({ open, onCancel, onSubmit }) {
const Container = ({ children, className }) => (
<Form onSubmit={data => onSubmit(data)}>
<Form onSubmit={data => onSubmit(data.error)}>
{({ formProps }) => (
<form {...formProps} className={className}>
{children}
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/modules/data/components/data-request/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,16 @@ function withRequest(Component) {
componentDidCatch(error, info) {
const { onError } = this.props;
const { message } = error;
const { componentStack } = info;

this.setState({
error: {
message,
info: info.componentStack,
info: componentStack,
},
});

onError(message);
onError(message, componentStack);
}

getParams = () => {
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/modules/data/components/error/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ const ReportErrorButton = reportErrorButton(props => (
));

function ErrorComponent({ data }) {
// {data.info}

return (
<div className={styles.container}>
<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ RequestsList.propTypes = {
_id: PropTypes.string,
name: PropTypes.string,
state: PropTypes.number,
}),
})
),
fetchRequests: PropTypes.func.isRequired,
filter: PropTypes.oneOfType([
Expand Down

0 comments on commit 751c8f5

Please sign in to comment.