language/move-stdlib/docs/Errors.md
<a name="0x1_Errors"></a>
0x1::ErrorsModule defining error codes used in Move aborts throughout the framework.
A <code>u64</code> error code is constructed from two values:
The error category which is encoded in the lower 8 bits of the code. Error categories are declared in this module and are globally unique across the Diem framework. There is a limited fixed set of predefined categories, and the framework is guaranteed to use those consistently.
The error reason which is encoded in the remaining 56 bits of the code. The reason is a unique number relative to the module which raised the error and can be used to obtain more information about the error at hand. It is mostly used for diagnosis purposes. Error reasons may change over time as the framework evolves.
TODO: determine what kind of stability guarantees we give about reasons/associated module.
makeinvalid_staterequires_addressrequires_rolerequires_capabilitynot_publishedalready_publishedinvalid_argumentlimit_exceededinternalcustom<a name="@Constants_0"></a>
<a name="0x1_Errors_ALREADY_PUBLISHED"></a>
Attempting to publish a resource that is already published. Example: calling an initialization function twice.
<pre><code><b>const</b> <a href="Errors.md#0x1_Errors_ALREADY_PUBLISHED">ALREADY_PUBLISHED</a>: u8 = 6; </code></pre><a name="0x1_Errors_CUSTOM"></a>
A custom error category for extension points.
<pre><code><b>const</b> <a href="Errors.md#0x1_Errors_CUSTOM">CUSTOM</a>: u8 = 255; </code></pre><a name="0x1_Errors_INTERNAL"></a>
An internal error (bug) has occurred.
<pre><code><b>const</b> <a href="Errors.md#0x1_Errors_INTERNAL">INTERNAL</a>: u8 = 10; </code></pre><a name="0x1_Errors_INVALID_ARGUMENT"></a>
An argument provided to an operation is invalid. Example: a signing key has the wrong format.
<pre><code><b>const</b> <a href="Errors.md#0x1_Errors_INVALID_ARGUMENT">INVALID_ARGUMENT</a>: u8 = 7; </code></pre><a name="0x1_Errors_INVALID_STATE"></a>
The system is in a state where the performed operation is not allowed. Example: call to a function only allowed in genesis.
<pre><code><b>const</b> <a href="Errors.md#0x1_Errors_INVALID_STATE">INVALID_STATE</a>: u8 = 1; </code></pre><a name="0x1_Errors_LIMIT_EXCEEDED"></a>
A limit on an amount, e.g. a currency, is exceeded. Example: withdrawal of money after account limits window is exhausted.
<pre><code><b>const</b> <a href="Errors.md#0x1_Errors_LIMIT_EXCEEDED">LIMIT_EXCEEDED</a>: u8 = 8; </code></pre><a name="0x1_Errors_NOT_PUBLISHED"></a>
A resource is required but not published. Example: access to non-existing AccountLimits resource.
<pre><code><b>const</b> <a href="Errors.md#0x1_Errors_NOT_PUBLISHED">NOT_PUBLISHED</a>: u8 = 5; </code></pre><a name="0x1_Errors_REQUIRES_ADDRESS"></a>
The signer of a transaction does not have the expected address for this operation. Example: a call to a function which publishes a resource under a particular address.
<pre><code><b>const</b> <a href="Errors.md#0x1_Errors_REQUIRES_ADDRESS">REQUIRES_ADDRESS</a>: u8 = 2; </code></pre><a name="0x1_Errors_REQUIRES_CAPABILITY"></a>
The signer of a transaction does not have a required capability.
<pre><code><b>const</b> <a href="Errors.md#0x1_Errors_REQUIRES_CAPABILITY">REQUIRES_CAPABILITY</a>: u8 = 4; </code></pre><a name="0x1_Errors_REQUIRES_ROLE"></a>
The signer of a transaction does not have the expected role for this operation. Example: a call to a function which requires the signer to have the role of treasury compliance.
<pre><code><b>const</b> <a href="Errors.md#0x1_Errors_REQUIRES_ROLE">REQUIRES_ROLE</a>: u8 = 3; </code></pre><a name="0x1_Errors_make"></a>
makeA function to create an error from from a category and a reason.
<pre><code><b>fun</b> <a href="Errors.md#0x1_Errors_make">make</a>(category: u8, reason: u64): u64 </code></pre> <details> <summary>Implementation</summary> <pre><code><b>fun</b> <a href="Errors.md#0x1_Errors_make">make</a>(category: u8, reason: u64): u64 { (category <b>as</b> u64) + (reason << 8) } </code></pre> </details> <details> <summary>Specification</summary> <pre><code><b>pragma</b> opaque = <b>true</b>; <b>ensures</b> [concrete] result == category + (reason << 8); <b>aborts_if</b> [abstract] <b>false</b>; <b>ensures</b> [abstract] result == category; </code></pre> </details><a name="0x1_Errors_invalid_state"></a>
invalid_state<a name="0x1_Errors_requires_address"></a>
requires_address<a name="0x1_Errors_requires_role"></a>
requires_role<a name="0x1_Errors_requires_capability"></a>
requires_capability<a name="0x1_Errors_not_published"></a>
not_published<a name="0x1_Errors_already_published"></a>
already_published<a name="0x1_Errors_invalid_argument"></a>
invalid_argument<a name="0x1_Errors_limit_exceeded"></a>
limit_exceeded<a name="0x1_Errors_internal"></a>
internal<a name="0x1_Errors_custom"></a>
custom