-
Notifications
You must be signed in to change notification settings - Fork 85
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
Add docs on clever errors #99
base: main
Are you sure you want to change the base?
Conversation
conditions and still get useful error messages. | ||
|
||
```move | ||
module 0x42::macro_exporter { |
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.
For coherence, I would split it into two codeblocks and use module labels.
> change due to any changes in the source file (e.g., due to auto-formatting, adding a new module | ||
> member, or adding a newline). | ||
|
||
## Clever Abort Codes |
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.
Can you add a link to a matching page in the book/
?
or an abort is raised. They are a source feature and compile to a `u64` abort code value that | ||
contains the information needed to access the line number, constant name, and constant value given | ||
the clever error code and the module that the clever error constant was declared in. Because of | ||
this, post-processing is required to go from the `u64` abort code value to a human-readable error |
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.
this, post-processing is required to go from the `u64` abort code value to a human-readable error | |
this compilation, post-processing is required to go from the `u64` abort code value to a human-readable error |
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.
Trying to be less ambiguous.
contains the information needed to access the line number, constant name, and constant value given | ||
the clever error code and the module that the clever error constant was declared in. Because of | ||
this, post-processing is required to go from the `u64` abort code value to a human-readable error | ||
message. This post-processing is automatically performed by the Sui GraphQL server, as well as the |
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.
message. This post-processing is automatically performed by the Sui GraphQL server, as well as the | |
message. The post-processing is automatically performed by the Sui GraphQL server, as well as the |
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 think this just reads cleaner given the previous sentence.
|
||
## Assertions with no Abort Codes | ||
|
||
Assertions, and `abort` statements without an abort code will automatically derive an abort code |
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.
Assertions, and `abort` statements without an abort code will automatically derive an abort code | |
Assertions and `abort` statements without an abort code will automatically derive an abort code |
In hex, if `double_except_three(3)` is called, it will abort with a `u64` abort code as follows: | ||
|
||
``` | ||
0x8000_7000_1000_0000 |
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.
0x8000_7000_1000_0000 | |
0x8000_0007_0001_0000 |
Is this correct? I was surprised that the value was set into the higher bits there.
In hex, if `assert_false(3)` is called, it will abort with a `u64` abort code as follows: | ||
|
||
``` | ||
0x8000_4000_ffff_ffff |
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.
Let's double check this with the one above
|
||
// Print the constant name (if any) | ||
if identifier_index != 0xffff { | ||
let constant_name = get_identifier_at_table_index(module, identifier_index); |
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.
get_identifier_at_table_index
I appreciate this is pseudo code, but do we have a method for this?
Adds docs on clever errors.