Frontend content such as the Discussion page or the IndexPage run calls to the API using the internal API client. When that process errors out, it is handled by the API error handler which means we get a JSON response other than what we expect, leading to incomprehensible error pages where the frontend is broken, even when it is a simple 404 or 403 exception.
In this case we want the exceptions/errors not to be handled by the API client, but instead propagate to the forum/admin error handler.
But there are other cases where we want the client to handle the errors, such as in a testing context where we might be testing error response structure.
This PR adds a way to tell the client when to handle errors and when not to do so. We tell the client not to handle errors for all preloaded content.
Necessity
[ ] Has the problem that is being solved here been clearly explained?
[ ] If applicable, have various options for solving this problem been considered?
[ ] For core PRs, does this need to be in core, or could it be in an extension?
[ ] Are we willing to maintain this for years / potentially forever?
Confirmed
[ ] Frontend changes: tested on a local Flarum installation.
[ ] Backend changes: tests are green (run composer test).
[ ] Core developer confirmed locally this works as intended.
[ ] Tests have been added, or are not appropriate here.
Fixes flarum/issue-archive#39
Changes proposed in this pull request:
Discussion
page or theIndexPage
run calls to the API using the internal API client. When that process errors out, it is handled by the API error handler which means we get a JSON response other than what we expect, leading to incomprehensible error pages where the frontend is broken, even when it is a simple 404 or 403 exception.Necessity
Confirmed
composer test
).