routeResolver.onmatch swallows errors
Mithril version: 2.0.3
Browser and OS: Chrome 76 on Win 10
Code
m.route(document.body, '/', {
'/': {
render() { return m('h3', 'Home page'); }
},
'/other': {
onmatch() { p('do something crazy'); x.y; p('done?'); },
render() { return m('h3', 'Other page'); }
}
});
m.route.set('other');
Steps to Reproduce
- Run the code.
- Look at the JS console.
Expected Behavior
Not sure what behavior should happen, but I do expect to see the error in the JS console.
Current Behavior
Routed to default route and no error is shown in the JS console.
Context
Makes it difficult to debug why an application is behaving in an unexpected way when you can't see the underlying error.
Pretty sure this is somewhat intentional, but not entirely. What it could do is rethrow the error on rejection, so it acts more properly like a finally.
I didn't design that part of the router, BTW. So I'm not sure what the rationale was, if it was in fact by design. I don't believe this part is tested for, so it might have been an oversight.