mirror of
https://github.com/LightZirconite/Microsoft-Rewards-Bot.git
synced 2026-01-11 09:46:16 +00:00
fix: Improve error handling and logging across multiple modules; enhance compatibility for legacy formats
This commit is contained in:
@@ -36,7 +36,7 @@ export class Retry {
|
||||
const util = new Util()
|
||||
const parse = (v: number | string) => {
|
||||
if (typeof v === 'number') return v
|
||||
try { return util.stringToMs(String(v)) } catch { return def.baseDelay }
|
||||
try { return util.stringToMs(String(v)) } catch { /* Invalid time string: fall back to default */ return def.baseDelay }
|
||||
}
|
||||
this.policy = {
|
||||
maxAttempts: (merged.maxAttempts as number) ?? def.maxAttempts,
|
||||
|
||||
@@ -249,9 +249,9 @@ export function log(isMobile: boolean | 'main', title: string, message: string,
|
||||
try {
|
||||
if (type in ntfyConditions && ntfyConditions[type as keyof typeof ntfyConditions].some(condition => condition)) {
|
||||
// Fire-and-forget
|
||||
Promise.resolve(Ntfy(cleanStr, type)).catch(() => { /* ignore ntfy errors */ })
|
||||
Promise.resolve(Ntfy(cleanStr, type)).catch(() => { /* Non-critical: NTFY notification errors are ignored */ })
|
||||
}
|
||||
} catch { /* ignore */ }
|
||||
} catch { /* Non-critical: Webhook buffer cleanup can fail safely */ }
|
||||
|
||||
// Console output with better formatting and contextual icons
|
||||
const typeIndicator = type === 'error' ? '✗' : type === 'warn' ? '⚠' : '✓'
|
||||
|
||||
@@ -86,7 +86,7 @@ function normalizeConfig(raw: unknown): Config {
|
||||
? true
|
||||
: (typeof browserConfig.headless === 'boolean'
|
||||
? browserConfig.headless
|
||||
: (typeof n.headless === 'boolean' ? n.headless : false)) // Legacy fallback
|
||||
: (typeof n.headless === 'boolean' ? n.headless : false)) // COMPATIBILITY: Flat headless field (pre-v2.50)
|
||||
|
||||
const globalTimeout = browserConfig.globalTimeout ?? n.globalTimeout ?? '30s'
|
||||
const browser: ConfigBrowser = {
|
||||
@@ -271,7 +271,7 @@ function buildSchedulingConfig(raw: unknown): ConfigScheduling | undefined {
|
||||
scheduling.time = timeField
|
||||
}
|
||||
|
||||
// Priority 2: Legacy cron format (backwards compatibility)
|
||||
// Priority 2: COMPATIBILITY format (cron.schedule field, pre-v2.58)
|
||||
const cronRaw = source.cron
|
||||
if (cronRaw && typeof cronRaw === 'object') {
|
||||
scheduling.cron = {
|
||||
@@ -315,7 +315,7 @@ export function loadAccounts(): Account[] {
|
||||
path.join(process.cwd(), file + 'c'), // cwd/accounts.jsonc
|
||||
path.join(process.cwd(), 'src', file), // cwd/src/accounts.json
|
||||
path.join(process.cwd(), 'src', file + 'c'), // cwd/src/accounts.jsonc
|
||||
path.join(__dirname, file), // dist/accounts.json (legacy)
|
||||
path.join(__dirname, file), // dist/accounts.json (compiled output)
|
||||
path.join(__dirname, file + 'c') // dist/accounts.jsonc
|
||||
]
|
||||
let chosen: string | null = null
|
||||
|
||||
Reference in New Issue
Block a user