{"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).","language":"javascript","status":"active","last_verified":"Sat Apr 25","install":{"commands":["npm install redux-catch"],"cli":null},"imports":["import reduxCatch from 'redux-catch';"],"auth":{"required":false,"env_vars":[]},"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}