From 9c6705f6ebfb72d595292eee04b14b04717dd771 Mon Sep 17 00:00:00 2001 From: Mike Graham Date: Thu, 20 Nov 2025 14:25:47 -0800 Subject: [PATCH] fix: 402 errors include payingUser and other informative details --- chaincode/src/fees/payFeeImmediatelyFromBalance.ts | 8 +++++--- chaincode/src/fees/splitFeeBurnAndTransfer.ts | 14 +++++++++----- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/chaincode/src/fees/payFeeImmediatelyFromBalance.ts b/chaincode/src/fees/payFeeImmediatelyFromBalance.ts index fef7e0cd39..5095c1c95d 100644 --- a/chaincode/src/fees/payFeeImmediatelyFromBalance.ts +++ b/chaincode/src/fees/payFeeImmediatelyFromBalance.ts @@ -87,9 +87,11 @@ export async function payFeeImmediatelyFromBalance(ctx: GalaChainContext, data: owner: payingUser, toBurn: [burnQuantity] }).catch((e: ChainError) => { - throw new PaymentRequiredError(`Failed to burnTokens fee: ${e.message}`, { - paymentQuantity: quantity.toString() - }); + throw new PaymentRequiredError( + `Payment Requiured. payImmediatelyFromBalance: burnTokens for payingUser: ${payingUser}, ` + + `quantity: ${quantity.toString()}, feeCode: ${feeCode}, failed with error: ${e.message}`, + { paymentQuantity: quantity.toString() } + ); }); } else if (splitFormula instanceof ChainError) { throw splitFormula; diff --git a/chaincode/src/fees/splitFeeBurnAndTransfer.ts b/chaincode/src/fees/splitFeeBurnAndTransfer.ts index 5c058bca2a..12ed85af5d 100644 --- a/chaincode/src/fees/splitFeeBurnAndTransfer.ts +++ b/chaincode/src/fees/splitFeeBurnAndTransfer.ts @@ -64,9 +64,11 @@ export async function splitFeeImmediatelyWithBurnAndTransfer( toBurn: [burnQuantity] }).catch((e) => { throw new PaymentRequiredError( - `Failed to burnTokens for splitFeeFormula: ` + + `Payment Required. Failed to burnTokens for splitFeeFormula: ` + + `for payingUser: ${payingUser} ` + `burnFeeQuantity: ${burnFeeQuantity.toString()}, ` + - `totalFeeQuantity: ${totalFeeQuantity.toString()}, with error: ${e.message}`, + `totalFeeQuantity: ${totalFeeQuantity.toString()}, ` + + `failed with error: ${e.message}`, { paymentQuantity: totalFeeQuantity.toString() } ); }); @@ -81,10 +83,12 @@ export async function splitFeeImmediatelyWithBurnAndTransfer( authorizedOnBehalf: undefined }).catch((e) => { throw new PaymentRequiredError( - `Failed to transferToken for splitFeeFormula: ` + + `Payment Required. Failed to transferToken for splitFeeFormula ` + + `defined for ${feeCode} feeCode: ` + + `from payingUser: ${payingUser}, to transferToUser: ${transfer.transferToUser}` + `transferQuantity: ${transfer.transferQuantity.toString()} ` + - `to identity: ${transfer.transferToUser}, ` + - `totalFeeQuantity: ${totalFeeQuantity.toString()}, with error: ${e.message}`, + `totalFeeQuantity: ${totalFeeQuantity.toString()}, ` + + `Received error: ${e.message}`, { paymentQuantity: totalFeeQuantity.toString() } ); });