@@ -278,7 +278,7 @@ export abstract class TransactionBuilder extends BaseTransactionBuilder {
278278 if ( e instanceof BuildTransactionError ) {
279279 throw e ;
280280 }
281- throw new BuildTransactionError ( `Error processing output: ${ e . message } ` ) ;
281+ throw new BuildTransactionError ( `Error processing output: ${ e . message ?? e } ` ) ;
282282 }
283283 } ) ;
284284 return change ;
@@ -311,21 +311,25 @@ export abstract class TransactionBuilder extends BaseTransactionBuilder {
311311 * @param address - Recipient address
312312 */
313313 private buildTokens ( asset : Asset , minAmountNeededForOneAssetOutput , outputs , address ) {
314- let txOutputBuilder = CardanoWasm . TransactionOutputBuilder . new ( ) ;
315- const toAddress = util . getWalletAddress ( address ) ;
316- txOutputBuilder = txOutputBuilder . with_address ( toAddress ) ;
317- let txOutputAmountBuilder = txOutputBuilder . next ( ) ;
318- const assetName = CardanoWasm . AssetName . new ( Buffer . from ( asset . asset_name , 'hex' ) ) ;
319- const policyId = CardanoWasm . ScriptHash . from_bytes ( Buffer . from ( asset . policy_id , 'hex' ) ) ;
320- const multiAsset = CardanoWasm . MultiAsset . new ( ) ;
321- const assets = CardanoWasm . Assets . new ( ) ;
322- assets . insert ( assetName , CardanoWasm . BigNum . from_str ( asset . quantity ) ) ;
323- multiAsset . insert ( policyId , assets ) ;
324-
325- txOutputAmountBuilder = txOutputAmountBuilder . with_coin_and_asset ( minAmountNeededForOneAssetOutput , multiAsset ) ;
326-
327- const txOutput = txOutputAmountBuilder . build ( ) ;
328- outputs . add ( txOutput ) ;
314+ try {
315+ let txOutputBuilder = CardanoWasm . TransactionOutputBuilder . new ( ) ;
316+ const toAddress = util . getWalletAddress ( address ) ;
317+ txOutputBuilder = txOutputBuilder . with_address ( toAddress ) ;
318+ let txOutputAmountBuilder = txOutputBuilder . next ( ) ;
319+ const assetName = CardanoWasm . AssetName . new ( Buffer . from ( asset . asset_name , 'hex' ) ) ;
320+ const policyId = CardanoWasm . ScriptHash . from_bytes ( Buffer . from ( asset . policy_id , 'hex' ) ) ;
321+ const multiAsset = CardanoWasm . MultiAsset . new ( ) ;
322+ const assets = CardanoWasm . Assets . new ( ) ;
323+ assets . insert ( assetName , CardanoWasm . BigNum . from_str ( asset . quantity ) ) ;
324+ multiAsset . insert ( policyId , assets ) ;
325+
326+ txOutputAmountBuilder = txOutputAmountBuilder . with_coin_and_asset ( minAmountNeededForOneAssetOutput , multiAsset ) ;
327+
328+ const txOutput = txOutputAmountBuilder . build ( ) ;
329+ outputs . add ( txOutput ) ;
330+ } catch ( e ) {
331+ throw new BuildTransactionError ( `Error building tokens: ${ e . message || e } for asset ${ JSON . stringify ( asset ) } ` ) ;
332+ }
329333 }
330334
331335 /**
0 commit comments