Composes an array of middlewares into a higher-order function that wraps a
game reducer.
Middleware ordering follows the Redux convention: the first middleware in
the array is the outermost layer — it sees the action first on the way in and
last on the way out.
Each middleware layer is wrapped in a try / catch. If a middleware throws, the
error is logged and the action falls through to the next layer so a single
broken middleware never tears down the entire dispatch chain. If the middleware
already called next before throwing, the error boundary returns the current
state instead of re-dispatching to prevent double-dispatch.
Composes an array of middlewares into a higher-order function that wraps a game reducer.
Middleware ordering follows the Redux convention: the first middleware in the array is the outermost layer — it sees the action first on the way in and last on the way out.
Each middleware layer is wrapped in a try / catch. If a middleware throws, the error is logged and the action falls through to the next layer so a single broken middleware never tears down the entire dispatch chain. If the middleware already called
nextbefore throwing, the error boundary returns the current state instead of re-dispatching to prevent double-dispatch.