Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass-through JS error to client #521

Merged
merged 4 commits into from
Aug 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Contributors: please follow the recommendations outlined at [keepachangelog.com]
- React on Rails now correctly parses single-digit version strings from package.json [#491](https://github.com/shakacode/react_on_rails/pull/491) by [samphilipd ](https://github.com/samphilipd ).
- Fixed assets symlinking to correctly use filenames with spaces. Begining in [#510](https://github.com/shakacode/react_on_rails/pull/510), ending in [#513](https://github.com/shakacode/react_on_rails/pull/513) by [dzirtusss](https://github.com/dzirtusss)
- Added authenticityToken() and authenticityHeaders() javascript helpers for easier use when working with CSRF protection tag generated by Rails [#517](https://github.com/shakacode/react_on_rails/pull/517) by [dzirtusss](https://github.com/dzirtusss)
- Updated JavaScript error handling on the client side from catching internally to passing through to the browser [#521](https://github.com/shakacode/react_on_rails/pull/521) by [dzirtusss](https://github.com/dzirtusss)


## [6.0.5] - 2016-07-11
##### Added
Expand Down
8 changes: 3 additions & 5 deletions node_package/src/clientStartup.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,9 @@ You should return a React.Component always for the client side entry point.`);
}
}
} catch (e) {
handleError({
e,
name,
serverSide: false,
});
e.message = `ReactOnRails encountered an error while rendering component: ${name}.` +
`Original message: ${e.message}`;
throw e;
}
}

Expand Down
4 changes: 3 additions & 1 deletion node_package/src/handleError.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ component \'${name}\' is not a generator function.\n${lastLine}`;
return msg;
}

export default (options) => {
const handleError = (options) => {
const { e, jsCode, serverSide } = options;

console.error('Exception in rendering!');
Expand Down Expand Up @@ -64,3 +64,5 @@ ${e.stack}`;
return ReactDOMServer.renderToString(reactElement);
}
};

export default handleError;