Skip to content

Commit 0ec6932

Browse files
kasbahjaredpalmer
authored andcommitted
Stop swallowing getInitialProps errors (jaredpalmer#151)
* Remove catch calls in loadInitialProps * Handle errors in example in a better way
1 parent 61c76ad commit 0ec6932

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

examples/basic/src/server.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ server
2222
});
2323
res.send(html);
2424
} catch (error) {
25-
res.json(error);
25+
console.error(error);
26+
res.json({ message: error.message, stack: error.stack });
2627
}
2728
});
2829

src/loadInitialProps.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@ export async function loadInitialProps(
1616
.then(() =>
1717
(route.component as any)
1818
.getInitialProps({ match, ...ctx })
19-
.catch(() => {})
2019
)
2120
: (route.component as any)
2221
.getInitialProps({ match, ...ctx })
23-
.catch(() => {})
2422
);
2523
}
2624
return match;

0 commit comments

Comments
 (0)