{"id":18723,"library":"redux-catch","title":"redux-catch","description":"Error catcher middleware for Redux that intercepts errors thrown in reducers and synchronous middlewares. Version 1.3.1 is the latest stable release, with infrequent updates. It allows you to provide a custom error handler function that receives the error, current state via getState, the last dispatched action, and a dispatch function. Unlike Redux's built-in error handling, redux-catch supports logging, reporting to services like Sentry, and optionally dispatching actions on errors. It should be placed as the first middleware in the chain. Comes as ES module (no Babel build, uses arrow functions).","status":"active","version":"1.3.1","language":"javascript","source_language":"en","source_url":"https://github.com/PlatziDev/redux-catch","tags":["javascript","redux","error","catch","middleware"],"install":[{"cmd":"npm install redux-catch","lang":"bash","label":"npm"},{"cmd":"yarn add redux-catch","lang":"bash","label":"yarn"},{"cmd":"pnpm add redux-catch","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package is ESM-only; commonJS require may fail in some bundlers.","wrong":"const reduxCatch = require('redux-catch');","symbol":"default (reduxCatch)","correct":"import reduxCatch from 'redux-catch';"}],"quickstart":{"code":"import { createStore, applyMiddleware } from 'redux';\nimport reduxCatch from 'redux-catch';\nimport reducer from './reducer';\n\nfunction errorHandler(error, getState, lastAction, dispatch) {\n  console.error('Error caught by middleware:', error);\n  console.debug('Current state:', getState());\n  console.debug('Last action:', lastAction);\n  // Optionally dispatch an error action: dispatch({ type: 'ERROR', payload: error });\n}\n\nconst store = createStore(\n  reducer,\n  applyMiddleware(reduxCatch(errorHandler))\n);\n\n// Usage: dispatching an action that causes an error in reducer will trigger errorHandler\nstore.dispatch({ type: 'INVALID_ACTION' });","lang":"javascript","description":"Creates a Redux store with the redux-catch middleware to catch errors from reducers and sync middlewares, logging them and optionally dispatching actions."},"warnings":[{"fix":"Use a different error handling pattern for async middleware (e.g., wrap your async thunks in try-catch).","message":"redux-catch only catches errors from reducers and synchronous middlewares, not from asynchronous middlewares or dispatched action creators.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure reduxCatch is the first argument to applyMiddleware, or positioned before other middleware.","message":"The middleware must be placed as the first middleware in the chain to catch errors from all subsequent middleware.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use function(error, getState, lastAction, dispatch) { ... } for v1.3.0+.","cause":"Using the error handler signature incorrectly; the getState parameter is the second argument, but may be destructured wrong if using older version.","error":"Uncaught TypeError: Cannot destructure property 'getState' of '...' as it is undefined."},{"fix":"Ensure your build system supports ES6 features; redux-catch uses arrow functions. Add babel-polyfill if needed for older environments.","cause":"The package uses async generators or ES6 features without proper transpiler setup.","error":"Uncaught ReferenceError: regeneratorRuntime is not defined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}