-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.js
More file actions
64 lines (57 loc) · 1.44 KB
/
Copy patherrors.js
File metadata and controls
64 lines (57 loc) · 1.44 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/**
* NAS100 Bot - 自定義錯誤類別
*/
// 基礎交易機器人錯誤
class TradingBotError extends Error {
constructor(message, code = 'UNKNOWN', details = {}) {
super(message);
this.name = 'TradingBotError';
this.code = code;
this.details = details;
this.timestamp = new Date();
}
toJSON() {
return {
name: this.name,
message: this.message,
code: this.code,
details: this.details,
timestamp: this.timestamp
};
}
}
// 連線錯誤
class ConnectionError extends TradingBotError {
constructor(message, details = {}) {
super(message, 'CONNECTION_ERROR', details);
this.name = 'ConnectionError';
}
}
// 訂單錯誤
class OrderError extends TradingBotError {
constructor(message, details = {}) {
super(message, 'ORDER_ERROR', details);
this.name = 'OrderError';
}
}
// 市場數據錯誤
class MarketDataError extends TradingBotError {
constructor(message, details = {}) {
super(message, 'MARKET_DATA_ERROR', details);
this.name = 'MarketDataError';
}
}
// 配置錯誤
class ConfigError extends TradingBotError {
constructor(message, details = {}) {
super(message, 'CONFIG_ERROR', details);
this.name = 'ConfigError';
}
}
module.exports = {
TradingBotError,
ConnectionError,
OrderError,
MarketDataError,
ConfigError
};