Error handling — silent failure
κ_a accumulatedasync function processPayment(userId, amount) {
try {
return await chargeAPI(userId, amount);
} catch (err) {
console.error(err); // κ_a
return { ok: false }; // fake recovery
}
}
async function processPayment(userId, amount) {
const result = await chargeAPI(userId, amount);
if (!result.ok) {
logger.error('payment_failed', {
userId, amount, code: result.errorCode
});
throw new PaymentError(result.errorCode);
}
return result.data;
}