-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy patherrors.js
More file actions
25 lines (20 loc) · 988 Bytes
/
errors.js
File metadata and controls
25 lines (20 loc) · 988 Bytes
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
const { specificErrors } = require('./map');
module.exports = ({defineError, getError, fetchErrors}) => {
if (!getError('aptra')) {
const Aptra = defineError('aptra', null, 'Aptra generic');
const CommandReject = defineError('commandReject', Aptra, 'Command reject');
defineError('timeout', Aptra, 'Transaction timed out');
defineError('decode', Aptra, 'No parser found');
defineError('unknownMessageClass', Aptra, 'Received unknown message class: {message class}');
Object.keys(specificErrors).forEach(key => {
defineError(key, CommandReject, specificErrors[key]);
});
}
const CommandReject = getError('aptra.commandReject');
const customReject = status => {
return (getError(`aptra.commandReject.${status}`) || defineError(status, CommandReject, 'Specific command reject'))({});
};
return Object.assign({
'aptra.customReject': customReject
}, fetchErrors('aptra'));
};