Skip to content

Commit 616325e

Browse files
committed
fix(logging): improve error messages and wallet ID logging
- Updated error handling in the batch snapshot orchestrator to provide clearer error messages. - Modified wallet ID logging to display a truncated version for better readability in logs.
1 parent 5da16be commit 616325e

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

scripts/batch-snapshot-orchestrator.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,8 @@ async function main() {
210210
await orchestrator.run();
211211
process.exit(0);
212212
} catch (error) {
213-
console.error('❌ Orchestrator execution failed:', error);
213+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
214+
console.error('❌ Orchestrator execution failed:', errorMessage);
214215
process.exit(1);
215216
}
216217
}

src/pages/api/v1/stats/run-snapshots-batch.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export default async function handler(
6969
console.warn('Unauthorized request attempt', {
7070
ip: req.headers['x-forwarded-for'] || req.connection.remoteAddress,
7171
userAgent: req.headers['user-agent'],
72-
authToken: authToken ? 'present' : 'missing',
72+
authTokenProvided: !!authToken,
7373
timestamp: new Date().toISOString()
7474
});
7575
return res.status(401).json({ error: "Unauthorized" });
@@ -127,7 +127,7 @@ export default async function handler(
127127

128128
for (const wallet of wallets) {
129129
try {
130-
console.log(` Processing wallet: (${wallet.id})`);
130+
console.log(` Processing wallet: (${wallet.id.slice(0, 8)}...)`);
131131

132132
// Determine network from signer addresses
133133
let network = 1; // Default to mainnet
@@ -158,7 +158,7 @@ export default async function handler(
158158

159159
const mWallet = buildMultisigWallet(walletData, network);
160160
if (!mWallet) {
161-
console.error(`Failed to build multisig wallet for ${wallet.id}`);
161+
console.error(`Failed to build multisig wallet for ${wallet.id.slice(0, 8)}...`);
162162
failedInBatch++;
163163
continue;
164164
}
@@ -194,7 +194,7 @@ export default async function handler(
194194
paymentUtxos = await blockchainProvider.fetchAddressUTxOs(paymentAddress);
195195
stakeableUtxos = await blockchainProvider.fetchAddressUTxOs(stakeableAddress);
196196
} catch (utxoError) {
197-
console.error(`Failed to fetch UTxOs for wallet ${wallet.id}:`, utxoError);
197+
console.error(`Failed to fetch UTxOs for wallet ${wallet.id.slice(0, 8)}...:`, utxoError);
198198
// Continue with empty UTxOs
199199
}
200200

@@ -214,9 +214,9 @@ export default async function handler(
214214
try {
215215
const fallbackProvider = getProvider(fallbackNetwork);
216216
utxos = await fallbackProvider.fetchAddressUTxOs(walletAddress);
217-
console.log(`Successfully fetched ${utxos.length} UTxOs for wallet ${wallet.id} on fallback network ${fallbackNetwork}`);
217+
console.log(`Successfully fetched ${utxos.length} UTxOs for wallet ${wallet.id.slice(0, 8)}... on fallback network ${fallbackNetwork}`);
218218
} catch (fallbackError) {
219-
console.error(`Failed to fetch UTxOs for wallet ${wallet.id} on fallback network ${fallbackNetwork}:`, fallbackError);
219+
console.error(`Failed to fetch UTxOs for wallet ${wallet.id.slice(0, 8)}... on fallback network ${fallbackNetwork}:`, fallbackError);
220220
// Continue with empty UTxOs - this wallet will show 0 balance
221221
}
222222
}
@@ -244,7 +244,7 @@ export default async function handler(
244244
console.log(` ✅ Balance: ${roundedAdaBalance} ADA`);
245245

246246
} catch (error) {
247-
console.error(`Error processing wallet ${wallet.id}:`, error);
247+
console.error(`Error processing wallet ${wallet.id.slice(0, 8)}...:`, error);
248248
failedInBatch++;
249249
}
250250
}
@@ -268,7 +268,7 @@ export default async function handler(
268268
});
269269
return 1;
270270
} catch (error) {
271-
console.error('Failed to store snapshot for wallet %s:', walletBalance.walletId, error);
271+
console.error('Failed to store snapshot for wallet %s:', walletBalance.walletId.slice(0, 8) + '...', error);
272272
return 0;
273273
}
274274
});

0 commit comments

Comments
 (0)