mirror of
https://github.com/samuelthomas2774/nxapi.git
synced 2026-04-22 06:57:14 -05:00
Fix error handling when using a presence URL
This commit is contained in:
parent
1a25639440
commit
f1ae5a7ea2
|
|
@ -179,21 +179,28 @@ export class ZncNotifications extends Loop {
|
|||
}
|
||||
|
||||
async handleError(err: ErrorResponse<CoralErrorResponse> | NodeJS.ErrnoException): Promise<LoopResult> {
|
||||
if ('code' in err && (err as any).type === 'system' && err.code === 'ETIMEDOUT') {
|
||||
debug('Request timed out, waiting %ds before retrying', this.update_interval, err);
|
||||
return handleError(err, this);
|
||||
}
|
||||
}
|
||||
|
||||
return LoopResult.OK;
|
||||
} else if ('code' in err && (err as any).type === 'system' && err.code === 'ENOTFOUND') {
|
||||
debug('Request error, waiting %ds before retrying', this.update_interval, err);
|
||||
export async function handleError(
|
||||
err: ErrorResponse<CoralErrorResponse> | NodeJS.ErrnoException,
|
||||
loop: Loop,
|
||||
): Promise<LoopResult> {
|
||||
if ('code' in err && (err as any).type === 'system' && err.code === 'ETIMEDOUT') {
|
||||
debug('Request timed out, waiting %ds before retrying', loop.update_interval, err);
|
||||
|
||||
return LoopResult.OK;
|
||||
} else if ('code' in err && (err as any).type === 'system' && err.code === 'EAI_AGAIN') {
|
||||
debug('Request error - name resolution failed, waiting %ds before retrying', this.update_interval, err);
|
||||
return LoopResult.OK;
|
||||
} else if ('code' in err && (err as any).type === 'system' && err.code === 'ENOTFOUND') {
|
||||
debug('Request error, waiting %ds before retrying', loop.update_interval, err);
|
||||
|
||||
return LoopResult.OK;
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
return LoopResult.OK;
|
||||
} else if ('code' in err && (err as any).type === 'system' && err.code === 'EAI_AGAIN') {
|
||||
debug('Request error - name resolution failed, waiting %ds before retrying', loop.update_interval, err);
|
||||
|
||||
return LoopResult.OK;
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import createDebug from 'debug';
|
|||
import { DiscordRpcClient, findDiscordRpcClient } from '../discord/rpc.js';
|
||||
import { getDiscordPresence, getInactiveDiscordPresence } from '../discord/util.js';
|
||||
import { DiscordPresencePlayTime, DiscordPresenceContext, DiscordPresence, ExternalMonitorConstructor, ExternalMonitor, ErrorResult } from '../discord/types.js';
|
||||
import { EmbeddedSplatNet2Monitor, ZncNotifications } from './notify.js';
|
||||
import { EmbeddedSplatNet2Monitor, handleError, ZncNotifications } from './notify.js';
|
||||
import { getPresenceFromUrl } from '../api/znc-proxy.js';
|
||||
import { ActiveEvent, CurrentUser, Friend, Game, Presence, PresenceState, CoralErrorResponse } from '../api/coral-types.js';
|
||||
import { ErrorResponse } from '../api/util.js';
|
||||
|
|
@ -604,4 +604,10 @@ export class ZncProxyDiscordPresence extends Loop {
|
|||
monitor.disable();
|
||||
}
|
||||
}
|
||||
|
||||
async handleError(err: ErrorResponse<CoralErrorResponse> | NodeJS.ErrnoException): Promise<LoopResult> {
|
||||
this.discord.onError(err);
|
||||
|
||||
return handleError(err, this);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user