-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathErrorHandler.js
More file actions
38 lines (34 loc) · 1.37 KB
/
ErrorHandler.js
File metadata and controls
38 lines (34 loc) · 1.37 KB
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
35
36
37
38
const Logger = new (require('../base/Logger'))();
class ErrorHandler {
constructor() {
/**
* @type {[{ errorCode: String, error?: String, params?: string[]}]}
*/
this.errors = [];
};
/**
* @param {{ errorCode: String, error?: String|Error, params?: string[]}} options
*/
resolveError(options = {}) {
let data = {
ClientLogin: 'Lütfen girdiğiniz tokeni kontrol edin.',
CmdLoadError: `${options.params[0]} adlı komut yüklenemedi lütfen komutu kontrol edin! Alınan hata: ${Logger.glue(options.error, Logger.colors.red)}`,
CmdRunError: `${options.params[0]} adlı komut yürütülürken bir hatayla karşılaşıldı. Alınan hata: ${Logger.glue(options.error, Logger.colors.red)}`
};
return data[options.errorCode];
};
/**
* @param {{ errorCode: String, error?: String, params?: string[]}} options
*/
error(options = {}) {
options = {
errorCode: options.errorCode || null,
error: options.error || null,
params: options.params || []
}
let out = this.resolveError(options);
this.errors.push(options);
Logger.errorLog(options.errorCode, Logger.glue(out, Logger.colors.yellow), { TitleColor: 'red' });
};
};
module.exports = ErrorHandler;