hookstore-error
v0.2.2
Published
simple error handler middleware for hookstore
Downloads
10
Maintainers
Readme
hookstore-error
error handler middeware for hookstore
Install
$ npm install hookstore-error
# or
$ yarn add hookstore-error
Usage
import { Provider, applyMiddlewares } from 'hookstore';
import errorHandler from 'hookstore-error';
const model = {
name: 'foo',
state: {},
actions: {},
};
function App() {
// App component code
}
function Root = () => {
const middlewares = [
errorHandler(),
// add other middlewares
];
applyMiddlewares(middlewares);
return <Provider model={model}><App /></Provider>;
}
ReactDOM.render(<Root />, document.querySelector('app'));
Custom error handle function for yourself:
function handleError(err) {
const { name, action, state } = this.ctx;
console.error(`${name}/${action} error`, err);
}
const middlewares = [
errorHandler({ error: handleError }),
// add other middlewares
];
applyMiddlewares(middlewares);
Injoy it!