Skip to content

Commit

Permalink
Pass-through JS error to client -- no catch in rendering (#521)
Browse files Browse the repository at this point in the history
* throws error on client
* moved throw from handleError to clientStartup
* modified message, updated js styling
  • Loading branch information
dzirtusss authored and justin808 committed Aug 19, 2016
1 parent a4d9033 commit 859ba1b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
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;

0 comments on commit 859ba1b

Please sign in to comment.