-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[VM] rename vm catchable and uncatchable exceptions #3538
Conversation
@roman-khimov @shargon please take a look, this is what i want to do with the exception currently. It just make it clear what the exception are and enfoce an exception message. If you think it is good to go, i will finish this pr. I think nothing will be influenced. |
Well, need to udpate UT still~~~ UTs are affected since exception type are different |
src/Neo.VM/VMCatchableException.cs
Outdated
if (string.IsNullOrEmpty(message)) | ||
throw new ArgumentException("Message cannot be null or empty.", nameof(message)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to avoid this, this error will be throw during runtime, is not a warning for us
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes remove this, and add a default message when null
.
src/Neo.VM/VMUncatchableException.cs
Outdated
if (string.IsNullOrEmpty(message)) | ||
throw new ArgumentException("Message cannot be null or empty.", nameof(message)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add default message on null
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, @Jim8y
src/Neo.VM/VMCatchableException.cs
Outdated
{ | ||
if (string.IsNullOrEmpty(message)) | ||
throw new ArgumentException("Message cannot be null or empty.", nameof(message)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Throw another Exception
when constructing an Exception
is not good practice.
src/Neo.VM/VMCatchableException.cs
Outdated
if (string.IsNullOrEmpty(message)) | ||
throw new ArgumentException("Message cannot be null or empty.", nameof(message)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes remove this, and add a default message when null
.
src/Neo.VM/VMUncatchableException.cs
Outdated
if (string.IsNullOrEmpty(message)) | ||
throw new ArgumentException("Message cannot be null or empty.", nameof(message)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add default message on null
.
@Jim8y please take a look that there are no any more left, and the most important, no changes in catchable exceptions |
|
||
namespace Neo.VM.Exceptions | ||
{ | ||
public interface IVMException |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making a requirement of for this is irrelevant, just use Exception
.
Doing this will make the message required for example:
public class BadScriptException(string message) : Exception(message) { }
{ | ||
} | ||
} | ||
public class VMCatchableException(string message) : Exception($"{message}"), IVMException; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the interface, its unneeded. also the $""
is unneeded too.
/// is not catchable by the VM, and will directly cause the VM execution to fault. | ||
/// </summary> | ||
/// <param name="message">The error message that explains the reason for the exception.</param> | ||
public class VmUncatchableException(string message) : Exception(message), IVMException |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the interface
Its hard to implement what i planed without change the exception name, maybe just keep it as it is. |
Description
This pr tries to improve the VM exception type and inforamtion, making it easier to understand the VM exception.
Fixes # #3536
Type of change
Test Configuration:
Checklist: