Add handling for websocket errors

This commit is contained in:
Matthias 2023-06-24 20:25:43 +02:00
parent 014663bb66
commit 0bb0c6a69b
2 changed files with 11 additions and 0 deletions

View File

@ -919,6 +919,9 @@ export function createBotSubStore(botId: string, botName: string) {
_handleWebsocketMessage(ws, event: MessageEvent<any>) { _handleWebsocketMessage(ws, event: MessageEvent<any>) {
const msg: FTWsMessage = JSON.parse(event.data); const msg: FTWsMessage = JSON.parse(event.data);
switch (msg.type) { switch (msg.type) {
case FtWsMessageTypes.exception:
showAlert(`WSException: ${msg.data}`, 'danger');
break;
case FtWsMessageTypes.whitelist: case FtWsMessageTypes.whitelist:
this.whitelist = msg.data; this.whitelist = msg.data;
break; break;

View File

@ -1,4 +1,6 @@
export enum FtWsMessageTypes { export enum FtWsMessageTypes {
exception = 'exception',
whitelist = 'whitelist', whitelist = 'whitelist',
entryFill = 'entry_fill', entryFill = 'entry_fill',
entryCancel = 'entry_cancel', entryCancel = 'entry_cancel',
@ -56,7 +58,13 @@ export interface FtNewCandleMessage extends FtBaseWsMessage {
// ... // ...
} }
export interface FtErrorMessage extends FtBaseWsMessage {
type: FtWsMessageTypes.exception;
data: string;
}
export type FTWsMessage = export type FTWsMessage =
| FtErrorMessage
| FtWhitelistMessage | FtWhitelistMessage
| FtEntryFillMessage | FtEntryFillMessage
| FTEntryCancelMessage | FTEntryCancelMessage