File size: 789 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const crashReporter = store => next => action => {
  // Handle THROW_ERROR actions
  if (action.type === 'THROW_ERROR') {
    console.error('Caught an exception!', action.err);
    if (process.env.NODE_ENV !== 'development') {
      window.Raven &&
        window.Raven.captureException(action.err, {
          extra: {
            action,
            state: store.getState(),
          },
        });
    }
  }

  try {
    return next(action);
  } catch (err) {
    console.error('Caught an exception!', err);
    if (process.env.NODE_ENV !== 'development') {
      window.Raven &&
        window.Raven.captureException(err, {
          extra: {
            action,
            state: store.getState(),
          },
        });
    }
    throw err;
  }
};

export default crashReporter;