Skip to content

Commit

Permalink
[fix] more informative SSR error (#1794)
Browse files Browse the repository at this point in the history
* [fix] more informative SSR error

* update test
  • Loading branch information
jchip committed Jan 27, 2021
1 parent 497defe commit a684d0a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions packages/electrode-react-webapp/lib/react-webapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,13 +242,16 @@ const resolveContent = (pathData, xrequire) => {
content: xrequire(mod)
};
} catch (error) {
const msg = `electrode-react-webapp: load SSR content ${mod} failed - ${error.message}`;
const msg = `electrode-react-webapp: failed to load SSR content from module ${mod}`;
console.error(msg, "\n", error); // eslint-disable-line
return {
fullPath: null,
error,
resolveTime,
content: msg
content: `<h1>electrode-react-webapp: SSR failed</h1>
<p>${msg}</p>
<pre>${error.stack}</pre>
`
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe("react-webapp", function() {
const f = "./test/data/bad-content.js";
const content = reactWebapp.resolveContent({ module: f });
intercept.restore();
expect(content.content).includes("test/data/bad-content.js failed");
expect(content.content).includes("test/data/bad-content.js");
expect(intercept.stderr.join("")).includes("Error: Cannot find module 'foo-blah'");
});

Expand Down

0 comments on commit a684d0a

Please sign in to comment.