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
|
import { Record, List } from 'immutable';
const ErrorsRecord = Record({
nextId: 0,
history: new List(),
});
export default class ErrorsState extends ErrorsRecord {
addError(error) {
const errorObject = new Error({ id: this.nextId, error: new ErrorBag(error) });
return this.set('history', this.history.push(errorObject)).set('nextId', this.nextId + 1);
}
}
const ErrorRecord = Record({
id: -1,
timestamp: new Date(),
error: new ErrorsRecord(),
});
export class Error extends ErrorRecord {}
const ErrorBagRecord = Record({
type: '',
position: 'bottom-left',
options: {
icon: 'error',
removeOnHover: true,
showCloseButton: true,
},
title: 'Unknown Error',
});
export class ErrorBag extends ErrorBagRecord {}
|