mirror of
https://github.com/discourse/discourse.git
synced 2025-01-30 05:01:44 +08:00
DEV: Catch errors in theme/plugin onPageChange handlers (#24784)
This makes the errors easier for admins to identify/resolve, and also prevents failures from affecting core functionality.
This commit is contained in:
parent
dcd81d56c0
commit
efbe5b7dda
|
@ -799,7 +799,8 @@ class PluginApi {
|
|||
```
|
||||
**/
|
||||
onPageChange(fn) {
|
||||
this.onAppEvent("page:changed", (data) => fn(data.url, data.title));
|
||||
const callback = wrapWithErrorHandler(fn, "broken_page_change_alert");
|
||||
this.onAppEvent("page:changed", (data) => callback(data.url, data.title));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -220,6 +220,7 @@ en:
|
|||
only_admins: "(this message is only shown to site administrators)"
|
||||
|
||||
broken_decorator_alert: "Posts may not display correctly because one of the post content decorators on your site raised an error."
|
||||
broken_page_change_alert: "An onPageChange handler raised an error. Check the browser developer tools for more information."
|
||||
|
||||
broken_plugin_alert: "Caused by plugin '%{name}'"
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user