Skip to content

Commit 19fe2e0

Browse files
committed
improve error message
1 parent d6d6488 commit 19fe2e0

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/components/ContractFunction.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,12 +290,20 @@ const ContractFunction: React.FC<Props> = ({ contractInfo, abi, provider, wallet
290290

291291
// check for mocknet
292292
if(provider instanceof MockNetworkProvider){
293-
await transaction.debug()
294-
alert(`Transaction evalution passed! Bitauth IDE link: ${await transaction.bitauthUri()}`)
293+
try{
294+
await transaction.debug()
295+
alert(`Transaction evalution passed! see Bitauth IDE link in console`)
296+
} catch(error) {
297+
const errorMessage = typeof error == "string" ? error : (error as Error)?.message
298+
const cashscriptError = errorMessage.split("Bitauth")[0]
299+
console.error(errorMessage)
300+
alert(`Transaction evalution failed with the following message: \n\n${cashscriptError} See Bitauth IDE link in console`)
301+
}
302+
295303
console.log(`Transaction evalution passed! Bitauth IDE link: ${await transaction.bitauthUri()}`)
296304
} else {
297305
const { txid } = await transaction.send()
298-
alert(`Transaction successfully sent: ${ExplorerString[provider.network]}/tx/${txid}`)
306+
alert(`Transaction successfully sent! see explorer link in console`)
299307
console.log(`Transaction successfully sent: ${ExplorerString[provider.network]}/tx/${txid}`)
300308
}
301309
updateUtxosContract(contract.name)

0 commit comments

Comments
 (0)