Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Commit

Permalink
Get innerException message Recursively (#630)
Browse files Browse the repository at this point in the history
* Fix Parse manifestFilePath

* merge master

* enable print exception message when deploy contract

* Add other error

* Add other

* Other error

* More errors

* Remove msg var

* fix

Co-authored-by: Shargon <shargon@gmail.com>
Co-authored-by: Luchuan <luchuan@neo.org>
  • Loading branch information
3 people authored Jul 24, 2020
1 parent dec52fb commit e5c7ccd
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 19 deletions.
8 changes: 4 additions & 4 deletions neo-cli/CLI/MainService.Contracts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ private void OnDeployCommand(string filePath, string manifestPath = null)
{
tx = CurrentWallet.MakeTransaction(script);
}
catch (InvalidOperationException)
catch (InvalidOperationException e)
{
Console.WriteLine("Engine faulted.");
Console.WriteLine("Error: " + GetExceptionMessage(e));
return;
}
Console.WriteLine($"Script hash: {scriptHash.ToString()}");
Expand Down Expand Up @@ -68,9 +68,9 @@ private void OnInvokeCommand(UInt160 scriptHash, string operation, JArray contra
{
tx = CurrentWallet.MakeTransaction(tx.Script, signers.Length > 0 ? signers[0].Account : null, signers);
}
catch (InvalidOperationException)
catch (InvalidOperationException e)
{
Console.WriteLine("Error: insufficient balance.");
Console.WriteLine("Error: " + GetExceptionMessage(e));
return;
}
if (!ReadUserInput("Relay tx(no|yes)").IsYes())
Expand Down
4 changes: 2 additions & 2 deletions neo-cli/CLI/MainService.NEP5.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ private void OnTransferCommand(UInt160 tokenHash, UInt160 to, decimal amount)
}
}, from: null);
}
catch (InvalidOperationException)
catch (InvalidOperationException e)
{
Console.WriteLine("Error: insufficient balance.");
Console.WriteLine("Error: " + GetExceptionMessage(e));
return;
}
if (!ReadUserInput("Relay tx(no|yes)").IsYes())
Expand Down
2 changes: 1 addition & 1 deletion neo-cli/CLI/MainService.Network.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ private void OnRelayCommand(JObject jsonObjectToRelay)
}
catch (Exception e)
{
Console.WriteLine($"One or more errors occurred:{Environment.NewLine}{e.Message}");
Console.WriteLine("Error: " + GetExceptionMessage(e));
}
}
}
Expand Down
16 changes: 5 additions & 11 deletions neo-cli/CLI/MainService.Wallet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ private void OnSignCommand(JObject jsonObjectToSign)
}
catch (Exception e)
{
Console.WriteLine($"One or more errors occurred:{Environment.NewLine}{e.Message}");
Console.WriteLine("Error: " + GetExceptionMessage(e));
}
}

Expand Down Expand Up @@ -523,26 +523,20 @@ private void SignAndSendTx(Transaction tx)
{
context = new ContractParametersContext(tx);
}
catch (InvalidOperationException ex)
catch (InvalidOperationException e)
{
Console.WriteLine($"Error creating contract params: {ex}");
Console.WriteLine($"Error creating contract params: " + GetExceptionMessage(e));
throw;
}
CurrentWallet.Sign(context);
string msg;
if (context.Completed)
{
tx.Witnesses = context.GetWitnesses();

NeoSystem.Blockchain.Tell(tx);

msg = $"Signed and relayed transaction with hash={tx.Hash}";
Console.WriteLine(msg);
Console.WriteLine($"Signed and relayed transaction with hash={tx.Hash}");
return;
}

msg = $"Failed sending transaction with hash={tx.Hash}";
Console.WriteLine(msg);
Console.WriteLine($"Failed sending transaction with hash={tx.Hash}");
}
}
}
2 changes: 1 addition & 1 deletion neo-cli/CLI/MainService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ static string GetExceptionMessage(Exception exception)

if (exception.InnerException != null)
{
return exception.InnerException.Message;
return GetExceptionMessage(exception.InnerException);
}

return exception.Message;
Expand Down

0 comments on commit e5c7ccd

Please sign in to comment.