From 285db974b733a3ab5f3dbd0501aff22c131c1b4f Mon Sep 17 00:00:00 2001
From: Hugo Trentesaux <hugo.trentesaux@lilo.org>
Date: Mon, 27 Nov 2023 14:00:28 +0100
Subject: [PATCH] add runtime errors doc (nodes/rust/duniter-v2s!204)

* also add runtime errors
---
 docs/api/runtime-errors.md            | 1491 +++++++++++++++++++++++++
 xtask/res/templates/runtime-errors.md |   21 +
 xtask/src/gen_doc.rs                  |   69 +-
 3 files changed, 1575 insertions(+), 6 deletions(-)
 create mode 100644 docs/api/runtime-errors.md
 create mode 100644 xtask/res/templates/runtime-errors.md

diff --git a/docs/api/runtime-errors.md b/docs/api/runtime-errors.md
new file mode 100644
index 000000000..425956424
--- /dev/null
+++ b/docs/api/runtime-errors.md
@@ -0,0 +1,1491 @@
+# Runtime errors
+
+There are **190** errors from **37** pallets.
+
+<ul>
+<li>System - 0
+<ul>
+<li>
+<details>
+<summary>
+<code>InvalidSpecName</code> - 0</summary>
+The name of specification does not match between the current runtime
+and the new runtime.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>SpecVersionNeedsToIncrease</code> - 1</summary>
+The specification version is not allowed to decrease between the current runtime
+and the new runtime.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>FailedToExtractRuntimeVersion</code> - 2</summary>
+Failed to extract the runtime version from the new runtime.
+
+Either calling `Core_version` or decoding `RuntimeVersion` failed.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>NonDefaultComposite</code> - 3</summary>
+Suicide called when the account has non-default composite data.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>NonZeroRefCount</code> - 4</summary>
+There is a non-zero reference count preventing the account from being purged.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>CallFiltered</code> - 5</summary>
+The origin filter prevent the call to be dispatched.
+</details>
+</li>
+</ul>
+</li>
+<li>Account - 1
+<ul>
+</ul>
+</li>
+<li>Scheduler - 2
+<ul>
+<li>
+<details>
+<summary>
+<code>FailedToSchedule</code> - 0</summary>
+Failed to schedule a call
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>NotFound</code> - 1</summary>
+Cannot find the scheduled call.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>TargetBlockNumberInPast</code> - 2</summary>
+Given target block number is in the past.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>RescheduleNoChange</code> - 3</summary>
+Reschedule failed because it does not change scheduled time.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>Named</code> - 4</summary>
+Attempt to use a non-named function on a named task.
+</details>
+</li>
+</ul>
+</li>
+<li>Babe - 3
+<ul>
+<li>
+<details>
+<summary>
+<code>InvalidEquivocationProof</code> - 0</summary>
+An equivocation proof provided as part of an equivocation report is invalid.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>InvalidKeyOwnershipProof</code> - 1</summary>
+A key ownership proof provided as part of an equivocation report is invalid.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>DuplicateOffenceReport</code> - 2</summary>
+A given equivocation report is valid but already previously reported.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>InvalidConfiguration</code> - 3</summary>
+Submitted configuration is invalid.
+</details>
+</li>
+</ul>
+</li>
+<li>Timestamp - 4
+<ul>
+</ul>
+</li>
+<li>Parameters - 5
+<ul>
+</ul>
+</li>
+<li>Balances - 6
+<ul>
+<li>
+<details>
+<summary>
+<code>VestingBalance</code> - 0</summary>
+Vesting balance too high to send value.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>LiquidityRestrictions</code> - 1</summary>
+Account liquidity restrictions prevent withdrawal.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>InsufficientBalance</code> - 2</summary>
+Balance too low to send value.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>ExistentialDeposit</code> - 3</summary>
+Value too low to create account due to existential deposit.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>Expendability</code> - 4</summary>
+Transfer/payment would kill account.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>ExistingVestingSchedule</code> - 5</summary>
+A vesting schedule already exists for this account.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>DeadAccount</code> - 6</summary>
+Beneficiary account must pre-exist.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>TooManyReserves</code> - 7</summary>
+Number of named reserves exceed `MaxReserves`.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>TooManyHolds</code> - 8</summary>
+Number of holds exceed `MaxHolds`.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>TooManyFreezes</code> - 9</summary>
+Number of freezes exceed `MaxFreezes`.
+</details>
+</li>
+</ul>
+</li>
+<li>TransactionPayment - 32
+<ul>
+</ul>
+</li>
+<li>OneshotAccount - 7
+<ul>
+<li>
+<details>
+<summary>
+<code>BlockHeightInFuture</code> - 0</summary>
+Block height is in the future
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>BlockHeightTooOld</code> - 1</summary>
+Block height is too old
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>DestAccountNotExist</code> - 2</summary>
+Destination account does not exist
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>ExistentialDeposit</code> - 3</summary>
+Destination account has balance less than existential deposit
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>InsufficientBalance</code> - 4</summary>
+Source account has insufficient balance
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>OneshotAccountAlreadyCreated</code> - 5</summary>
+Destination oneshot account already exists
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>OneshotAccountNotExist</code> - 6</summary>
+Source oneshot account does not exist
+</details>
+</li>
+</ul>
+</li>
+<li>Quota - 66
+<ul>
+</ul>
+</li>
+<li>AuthorityMembers - 10
+<ul>
+<li>
+<details>
+<summary>
+<code>AlreadyIncoming</code> - 0</summary>
+Already incoming
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>AlreadyOnline</code> - 1</summary>
+Already online
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>AlreadyOutgoing</code> - 2</summary>
+Already outgoing
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>MemberIdNotFound</code> - 3</summary>
+Not found owner key
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>MemberIdBlackListed</code> - 4</summary>
+Member is blacklisted
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>MemberNotBlackListed</code> - 5</summary>
+Member is not blacklisted
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>MemberNotFound</code> - 6</summary>
+Member not found
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>NotOnlineNorIncoming</code> - 7</summary>
+Neither online nor scheduled
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>NotOwner</code> - 8</summary>
+Not owner
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>NotMember</code> - 9</summary>
+Not member
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>SessionKeysNotProvided</code> - 10</summary>
+Session keys not provided
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>TooManyAuthorities</code> - 11</summary>
+Too man aAuthorities
+</details>
+</li>
+</ul>
+</li>
+<li>Authorship - 11
+<ul>
+</ul>
+</li>
+<li>Offences - 12
+<ul>
+</ul>
+</li>
+<li>Historical - 13
+<ul>
+</ul>
+</li>
+<li>Session - 14
+<ul>
+<li>
+<details>
+<summary>
+<code>InvalidProof</code> - 0</summary>
+Invalid ownership proof.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>NoAssociatedValidatorId</code> - 1</summary>
+No associated validator ID for account.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>DuplicatedKey</code> - 2</summary>
+Registered duplicate key.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>NoKeys</code> - 3</summary>
+No keys are associated with this account.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>NoAccount</code> - 4</summary>
+Key setting account is not live, so it's impossible to associate keys.
+</details>
+</li>
+</ul>
+</li>
+<li>Grandpa - 15
+<ul>
+<li>
+<details>
+<summary>
+<code>PauseFailed</code> - 0</summary>
+Attempt to signal GRANDPA pause when the authority set isn't live
+(either paused or already pending pause).
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>ResumeFailed</code> - 1</summary>
+Attempt to signal GRANDPA resume when the authority set isn't paused
+(either live or already pending resume).
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>ChangePending</code> - 2</summary>
+Attempt to signal GRANDPA change with one already pending.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>TooSoon</code> - 3</summary>
+Cannot signal forced change so soon after last.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>InvalidKeyOwnershipProof</code> - 4</summary>
+A key ownership proof provided as part of an equivocation report is invalid.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>InvalidEquivocationProof</code> - 5</summary>
+An equivocation proof provided as part of an equivocation report is invalid.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>DuplicateOffenceReport</code> - 6</summary>
+A given equivocation report is valid but already previously reported.
+</details>
+</li>
+</ul>
+</li>
+<li>ImOnline - 16
+<ul>
+<li>
+<details>
+<summary>
+<code>InvalidKey</code> - 0</summary>
+Non existent public key.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>DuplicatedHeartbeat</code> - 1</summary>
+Duplicated heartbeat.
+</details>
+</li>
+</ul>
+</li>
+<li>AuthorityDiscovery - 17
+<ul>
+</ul>
+</li>
+<li>Sudo - 20
+<ul>
+<li>
+<details>
+<summary>
+<code>RequireSudo</code> - 0</summary>
+Sender must be the Sudo account
+</details>
+</li>
+</ul>
+</li>
+<li>UpgradeOrigin - 21
+<ul>
+</ul>
+</li>
+<li>Preimage - 22
+<ul>
+<li>
+<details>
+<summary>
+<code>TooBig</code> - 0</summary>
+Preimage is too large to store on-chain.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>AlreadyNoted</code> - 1</summary>
+Preimage has already been noted on-chain.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>NotAuthorized</code> - 2</summary>
+The user is not authorized to perform this action.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>NotNoted</code> - 3</summary>
+The preimage cannot be removed since it has not yet been noted.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>Requested</code> - 4</summary>
+A preimage may not be removed when there are outstanding requests.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>NotRequested</code> - 5</summary>
+The preimage request cannot be removed since no outstanding requests exist.
+</details>
+</li>
+</ul>
+</li>
+<li>TechnicalCommittee - 23
+<ul>
+<li>
+<details>
+<summary>
+<code>NotMember</code> - 0</summary>
+Account is not a member
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>DuplicateProposal</code> - 1</summary>
+Duplicate proposals not allowed
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>ProposalMissing</code> - 2</summary>
+Proposal must exist
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>WrongIndex</code> - 3</summary>
+Mismatched index
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>DuplicateVote</code> - 4</summary>
+Duplicate vote ignored
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>AlreadyInitialized</code> - 5</summary>
+Members are already initialized!
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>TooEarly</code> - 6</summary>
+The close call was made too early, before the end of the voting.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>TooManyProposals</code> - 7</summary>
+There can only be a maximum of `MaxProposals` active proposals.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>WrongProposalWeight</code> - 8</summary>
+The given weight bound for the proposal was too low.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>WrongProposalLength</code> - 9</summary>
+The given length bound for the proposal was too low.
+</details>
+</li>
+</ul>
+</li>
+<li>UniversalDividend - 30
+<ul>
+<li>
+<details>
+<summary>
+<code>AccountNotAllowedToClaimUds</code> - 0</summary>
+This account is not allowed to claim UDs.
+</details>
+</li>
+</ul>
+</li>
+<li>Wot - 40
+<ul>
+<li>
+<details>
+<summary>
+<code>NotEnoughCertsToClaimMembership</code> - 0</summary>
+Not enough certifications received to claim membership
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>DistanceNotOK</code> - 1</summary>
+Distance has not been evaluated positively
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>IdtyNotAllowedToRequestMembership</code> - 2</summary>
+Identity not allowed to request membership
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>IdtyNotAllowedToRenewMembership</code> - 3</summary>
+Identity not allowed to renew membership
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>IdtyCreationPeriodNotRespected</code> - 4</summary>
+Identity creation period not respected
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>NotEnoughReceivedCertsToCreateIdty</code> - 5</summary>
+Not enough received certifications to create identity
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>MaxEmittedCertsReached</code> - 6</summary>
+Max number of emitted certs reached
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>NotAllowedToChangeIdtyAddress</code> - 7</summary>
+Not allowed to change identity address
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>NotAllowedToRemoveIdty</code> - 8</summary>
+Not allowed to remove identity
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>IssuerCanNotEmitCert</code> - 9</summary>
+Issuer can not emit cert because it is not validated
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>CertToUndefined</code> - 10</summary>
+Can not issue cert to identity without membership or pending membership
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>IdtyNotFound</code> - 11</summary>
+Issuer or receiver not found
+</details>
+</li>
+</ul>
+</li>
+<li>Identity - 41
+<ul>
+<li>
+<details>
+<summary>
+<code>IdtyAlreadyConfirmed</code> - 0</summary>
+Identity already confirmed
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>IdtyAlreadyCreated</code> - 1</summary>
+Identity already created
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>IdtyAlreadyValidated</code> - 2</summary>
+Identity already validated
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>IdtyCreationNotAllowed</code> - 3</summary>
+You are not allowed to create a new identity now
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>IdtyIndexNotFound</code> - 4</summary>
+Identity index not found
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>IdtyNameAlreadyExist</code> - 5</summary>
+Identity name already exists
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>IdtyNameInvalid</code> - 6</summary>
+Invalid identity name
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>IdtyNotConfirmedByOwner</code> - 7</summary>
+Identity not confirmed by its owner
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>IdtyNotFound</code> - 8</summary>
+Identity not found
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>IdtyNotMember</code> - 9</summary>
+Identity not member
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>IdtyNotValidated</code> - 10</summary>
+Identity not validated
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>IdtyNotYetRenewable</code> - 11</summary>
+Identity not yet renewable
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>InvalidSignature</code> - 12</summary>
+payload signature is invalid
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>InvalidRevocationKey</code> - 13</summary>
+Revocation key is invalid
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>NotRespectIdtyCreationPeriod</code> - 14</summary>
+Identity creation period is not respected
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>NotSameIdtyName</code> - 15</summary>
+Not the same identity name
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>OwnerKeyAlreadyRecentlyChanged</code> - 16</summary>
+Owner key already recently changed
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>OwnerKeyAlreadyUsed</code> - 17</summary>
+Owner key already used
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>ProhibitedToRevertToAnOldKey</code> - 18</summary>
+Prohibited to revert to an old key
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>RightAlreadyAdded</code> - 19</summary>
+Right already added
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>RightNotExist</code> - 20</summary>
+Right does not exist
+</details>
+</li>
+</ul>
+</li>
+<li>Membership - 42
+<ul>
+<li>
+<details>
+<summary>
+<code>IdtyIdNotFound</code> - 0</summary>
+Identity id not found
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>MembershipAlreadyAcquired</code> - 1</summary>
+Membership already acquired
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>MembershipAlreadyRequested</code> - 2</summary>
+Membership already requested
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>MembershipNotFound</code> - 3</summary>
+Membership not found
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>OriginNotAllowedToUseIdty</code> - 4</summary>
+Origin not allowed to use this identity
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>MembershipRequestNotFound</code> - 5</summary>
+Membership request not found
+</details>
+</li>
+</ul>
+</li>
+<li>Cert - 43
+<ul>
+<li>
+<details>
+<summary>
+<code>CannotCertifySelf</code> - 0</summary>
+An identity cannot certify itself
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>IssuedTooManyCert</code> - 1</summary>
+This identity has already issued the maximum number of certifications
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>IssuerNotFound</code> - 2</summary>
+Issuer not found
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>NotEnoughCertReceived</code> - 3</summary>
+Not enough certifications received
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>NotRespectCertPeriod</code> - 4</summary>
+This identity has already issued a certification too recently
+</details>
+</li>
+</ul>
+</li>
+<li>Distance - 44
+<ul>
+<li>
+<details>
+<summary>
+<code>AlreadyInEvaluation</code> - 0</summary>
+
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>CannotReserve</code> - 1</summary>
+
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>ManyEvaluationsByAuthor</code> - 2</summary>
+
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>ManyEvaluationsInBlock</code> - 3</summary>
+
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>NoAuthor</code> - 4</summary>
+
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>NoIdentity</code> - 5</summary>
+
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>NonEligibleForEvaluation</code> - 6</summary>
+
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>QueueFull</code> - 7</summary>
+
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>TooManyEvaluators</code> - 8</summary>
+
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>WrongResultLength</code> - 9</summary>
+
+</details>
+</li>
+</ul>
+</li>
+<li>SmithSubWot - 50
+<ul>
+<li>
+<details>
+<summary>
+<code>NotEnoughCertsToClaimMembership</code> - 0</summary>
+Not enough certifications received to claim membership
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>DistanceNotOK</code> - 1</summary>
+Distance has not been evaluated positively
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>IdtyNotAllowedToRequestMembership</code> - 2</summary>
+Identity not allowed to request membership
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>IdtyNotAllowedToRenewMembership</code> - 3</summary>
+Identity not allowed to renew membership
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>IdtyCreationPeriodNotRespected</code> - 4</summary>
+Identity creation period not respected
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>NotEnoughReceivedCertsToCreateIdty</code> - 5</summary>
+Not enough received certifications to create identity
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>MaxEmittedCertsReached</code> - 6</summary>
+Max number of emitted certs reached
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>NotAllowedToChangeIdtyAddress</code> - 7</summary>
+Not allowed to change identity address
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>NotAllowedToRemoveIdty</code> - 8</summary>
+Not allowed to remove identity
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>IssuerCanNotEmitCert</code> - 9</summary>
+Issuer can not emit cert because it is not validated
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>CertToUndefined</code> - 10</summary>
+Can not issue cert to identity without membership or pending membership
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>IdtyNotFound</code> - 11</summary>
+Issuer or receiver not found
+</details>
+</li>
+</ul>
+</li>
+<li>SmithMembership - 52
+<ul>
+<li>
+<details>
+<summary>
+<code>IdtyIdNotFound</code> - 0</summary>
+Identity id not found
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>MembershipAlreadyAcquired</code> - 1</summary>
+Membership already acquired
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>MembershipAlreadyRequested</code> - 2</summary>
+Membership already requested
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>MembershipNotFound</code> - 3</summary>
+Membership not found
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>OriginNotAllowedToUseIdty</code> - 4</summary>
+Origin not allowed to use this identity
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>MembershipRequestNotFound</code> - 5</summary>
+Membership request not found
+</details>
+</li>
+</ul>
+</li>
+<li>SmithCert - 53
+<ul>
+<li>
+<details>
+<summary>
+<code>CannotCertifySelf</code> - 0</summary>
+An identity cannot certify itself
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>IssuedTooManyCert</code> - 1</summary>
+This identity has already issued the maximum number of certifications
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>IssuerNotFound</code> - 2</summary>
+Issuer not found
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>NotEnoughCertReceived</code> - 3</summary>
+Not enough certifications received
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>NotRespectCertPeriod</code> - 4</summary>
+This identity has already issued a certification too recently
+</details>
+</li>
+</ul>
+</li>
+<li>AtomicSwap - 60
+<ul>
+<li>
+<details>
+<summary>
+<code>AlreadyExist</code> - 0</summary>
+Swap already exists.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>InvalidProof</code> - 1</summary>
+Swap proof is invalid.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>ProofTooLarge</code> - 2</summary>
+Proof is too large.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>SourceMismatch</code> - 3</summary>
+Source does not match.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>AlreadyClaimed</code> - 4</summary>
+Swap has already been claimed.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>NotExist</code> - 5</summary>
+Swap does not exist.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>ClaimActionMismatch</code> - 6</summary>
+Claim action mismatch.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>DurationNotPassed</code> - 7</summary>
+Duration has not yet passed for the swap to be cancelled.
+</details>
+</li>
+</ul>
+</li>
+<li>Multisig - 61
+<ul>
+<li>
+<details>
+<summary>
+<code>MinimumThreshold</code> - 0</summary>
+Threshold must be 2 or greater.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>AlreadyApproved</code> - 1</summary>
+Call is already approved by this signatory.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>NoApprovalsNeeded</code> - 2</summary>
+Call doesn't need any (more) approvals.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>TooFewSignatories</code> - 3</summary>
+There are too few signatories in the list.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>TooManySignatories</code> - 4</summary>
+There are too many signatories in the list.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>SignatoriesOutOfOrder</code> - 5</summary>
+The signatories were provided out of order; they should be ordered.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>SenderInSignatories</code> - 6</summary>
+The sender was contained in the other signatories; it shouldn't be.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>NotFound</code> - 7</summary>
+Multisig operation not found when attempting to cancel.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>NotOwner</code> - 8</summary>
+Only the account that originally created the multisig is able to cancel it.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>NoTimepoint</code> - 9</summary>
+No timepoint was given, yet the multisig operation is already underway.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>WrongTimepoint</code> - 10</summary>
+A different timepoint was given to the multisig operation that is underway.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>UnexpectedTimepoint</code> - 11</summary>
+A timepoint was given, yet no multisig operation is underway.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>MaxWeightTooLow</code> - 12</summary>
+The maximum weight information provided was too low.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>AlreadyStored</code> - 13</summary>
+The data to be stored is already stored.
+</details>
+</li>
+</ul>
+</li>
+<li>ProvideRandomness - 62
+<ul>
+<li>
+<details>
+<summary>
+<code>FullQueue</code> - 0</summary>
+The queue is full, pleasy retry later
+</details>
+</li>
+</ul>
+</li>
+<li>Proxy - 63
+<ul>
+<li>
+<details>
+<summary>
+<code>TooMany</code> - 0</summary>
+There are too many proxies registered or too many announcements pending.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>NotFound</code> - 1</summary>
+Proxy registration not found.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>NotProxy</code> - 2</summary>
+Sender is not a proxy of the account to be proxied.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>Unproxyable</code> - 3</summary>
+A call which is incompatible with the proxy type's filter was attempted.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>Duplicate</code> - 4</summary>
+Account is already a proxy.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>NoPermission</code> - 5</summary>
+Call may not be made by proxy because it may escalate its privileges.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>Unannounced</code> - 6</summary>
+Announcement, if made at all, was made too recently.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>NoSelfProxy</code> - 7</summary>
+Cannot add self as proxy.
+</details>
+</li>
+</ul>
+</li>
+<li>Utility - 64
+<ul>
+<li>
+<details>
+<summary>
+<code>TooManyCalls</code> - 0</summary>
+Too many calls batched.
+</details>
+</li>
+</ul>
+</li>
+<li>Treasury - 65
+<ul>
+<li>
+<details>
+<summary>
+<code>InsufficientProposersBalance</code> - 0</summary>
+Proposer's balance is too low.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>InvalidIndex</code> - 1</summary>
+No proposal or bounty at that index.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>TooManyApprovals</code> - 2</summary>
+Too many approvals in the queue.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>InsufficientPermission</code> - 3</summary>
+The spend origin is valid but the amount it is allowed to spend is lower than the
+amount to be spent.
+</details>
+</li>
+<li>
+<details>
+<summary>
+<code>ProposalNotApproved</code> - 4</summary>
+Proposal has not been approved.
+</details>
+</li>
+</ul>
+</li>
+</ul>
\ No newline at end of file
diff --git a/xtask/res/templates/runtime-errors.md b/xtask/res/templates/runtime-errors.md
new file mode 100644
index 000000000..7c477bd31
--- /dev/null
+++ b/xtask/res/templates/runtime-errors.md
@@ -0,0 +1,21 @@
+# Runtime errors
+
+There are **{{error_counter}}** errors from **{{ pallets | length }}** pallets.
+
+<ul>
+{% for pallet in pallets -%}
+<li>{{ pallet.name }} - {{ pallet.index }}
+<ul>
+{% for error in pallet.errors -%}
+<li>
+<details>
+<summary>
+<code>{{ error.name }}</code> - {{ error.index }}</summary>
+{{ error.documentation }}
+</details>
+</li>
+{% endfor -%}
+</ul>
+</li>
+{% endfor -%}
+</ul>
\ No newline at end of file
diff --git a/xtask/src/gen_doc.rs b/xtask/src/gen_doc.rs
index 5fb1f56a3..cbda42494 100644
--- a/xtask/src/gen_doc.rs
+++ b/xtask/src/gen_doc.rs
@@ -28,6 +28,7 @@ use tera::Tera;
 
 const CALLS_DOC_FILEPATH: &str = "docs/api/runtime-calls.md";
 const EVENTS_DOC_FILEPATH: &str = "docs/api/runtime-events.md";
+const ERRORS_DOC_FILEPATH: &str = "docs/api/runtime-errors.md";
 const TEMPLATES_GLOB: &str = "xtask/res/templates/*.md";
 
 // define structs and implementations
@@ -40,6 +41,7 @@ struct Pallet {
     name: String,
     calls: Vec<Call>,
     events: Vec<Event>,
+    errors: Vec<ErroR>,
 }
 #[derive(Clone, Serialize)]
 struct Call {
@@ -65,6 +67,12 @@ struct EventParam {
     name: String,
     type_name: String,
 }
+#[derive(Clone, Serialize)]
+struct ErroR {
+    documentation: String,
+    index: u8,
+    name: String,
+}
 
 impl Pallet {
     fn new(
@@ -72,6 +80,7 @@ impl Pallet {
         name: String,
         call_scale_type_def: &Option<scale_info::TypeDef<PortableForm>>,
         event_scale_type_def: &Option<scale_info::TypeDef<PortableForm>>,
+        error_scale_type_def: &Option<scale_info::TypeDef<PortableForm>>,
     ) -> Result<Self> {
         let calls = if let Some(call_scale_type_def) = call_scale_type_def {
             if let scale_info::TypeDef::Variant(calls_enum) = call_scale_type_def {
@@ -91,11 +100,21 @@ impl Pallet {
         } else {
             vec![]
         };
+        let errors = if let Some(error_scale_type_def) = error_scale_type_def {
+            if let scale_info::TypeDef::Variant(errors_enum) = error_scale_type_def {
+                errors_enum.variants.iter().map(Into::into).collect()
+            } else {
+                bail!("Invalid metadata")
+            }
+        } else {
+            vec![]
+        };
         Ok(Self {
             index,
             name,
             calls,
             events,
+            errors,
         })
     }
 }
@@ -116,7 +135,6 @@ impl From<&scale_info::Variant<PortableForm>> for Call {
         }
     }
 }
-
 impl From<&scale_info::Field<PortableForm>> for CallParam {
     fn from(field: &scale_info::Field<PortableForm>) -> Self {
         Self {
@@ -136,7 +154,6 @@ impl From<&scale_info::Variant<PortableForm>> for Event {
         }
     }
 }
-
 impl From<&scale_info::Field<PortableForm>> for EventParam {
     fn from(field: &scale_info::Field<PortableForm>) -> Self {
         Self {
@@ -146,6 +163,16 @@ impl From<&scale_info::Field<PortableForm>> for EventParam {
     }
 }
 
+impl From<&scale_info::Variant<PortableForm>> for ErroR {
+    fn from(variant: &scale_info::Variant<PortableForm>) -> Self {
+        Self {
+            documentation: variant.docs.iter().cloned().collect::<Vec<_>>().join("\n"),
+            index: variant.index,
+            name: variant.name.to_owned(),
+        }
+    }
+}
+
 enum CallCategory {
     Disabled,
     Inherent,
@@ -217,7 +244,7 @@ pub(super) fn gen_doc() -> Result<()> {
         bail!("unsuported metadata version")
     };
 
-    let (call_doc, event_doc) = print_runtime(runtime);
+    let (call_doc, event_doc, error_doc) = print_runtime(runtime);
 
     let mut file = File::create(CALLS_DOC_FILEPATH)
         .with_context(|| format!("Failed to create file '{}'", CALLS_DOC_FILEPATH))?;
@@ -227,6 +254,10 @@ pub(super) fn gen_doc() -> Result<()> {
         .with_context(|| format!("Failed to create file '{}'", EVENTS_DOC_FILEPATH))?;
     file.write_all(event_doc.as_bytes())
         .with_context(|| format!("Failed to write to file '{}'", EVENTS_DOC_FILEPATH))?;
+    let mut file = File::create(ERRORS_DOC_FILEPATH)
+        .with_context(|| format!("Failed to create file '{}'", ERRORS_DOC_FILEPATH))?;
+    file.write_all(error_doc.as_bytes())
+        .with_context(|| format!("Failed to write to file '{}'", ERRORS_DOC_FILEPATH))?;
 
     Ok(())
 }
@@ -255,12 +286,22 @@ fn get_from_metadata_v14(
             println!("{}: {} (0 events)", pallet.index, pallet.name);
             None
         };
+        let errors_type_def = if let Some(errors) = pallet.error {
+            let Some(errors_type) = metadata_v14.types.resolve(errors.ty.id) else {
+                bail!("Invalid metadata")
+            };
+            Some(errors_type.type_def.clone())
+        } else {
+            println!("{}: {} (0 errors)", pallet.index, pallet.name);
+            None
+        };
 
         let pallet = Pallet::new(
             pallet.index,
             pallet.name.clone(),
             &calls_type_def,
             &events_type_def,
+            &errors_type_def,
         )?;
 
         println!(
@@ -275,13 +316,19 @@ fn get_from_metadata_v14(
             pallet.name,
             pallet.events.len()
         );
+        println!(
+            "{}: {} ({} errors)",
+            pallet.index,
+            pallet.name,
+            pallet.errors.len()
+        );
         pallets.push(pallet);
     }
     Ok(pallets)
 }
 
 /// use template to render markdown file with runtime calls documentation
-fn print_runtime(pallets: RuntimePallets) -> (String, String) {
+fn print_runtime(pallets: RuntimePallets) -> (String, String, String) {
     // init variables
     let mut user_calls_counter = 0;
     let user_calls_pallets: RuntimePallets = pallets
@@ -340,6 +387,11 @@ fn print_runtime(pallets: RuntimePallets) -> (String, String) {
         .iter()
         .for_each(|pallet| event_counter += pallet.events.len());
 
+    let mut error_counter = 0;
+    pallets
+        .iter()
+        .for_each(|pallet| error_counter += pallet.errors.len());
+
     // compile template
     let tera = match Tera::new(TEMPLATES_GLOB) {
         Ok(t) => t,
@@ -363,12 +415,17 @@ fn print_runtime(pallets: RuntimePallets) -> (String, String) {
         .expect("template error");
 
     // render events
-
     context.insert("pallets", &pallets);
     context.insert("event_counter", &event_counter);
     let event_doc = tera
         .render("runtime-events.md", &context)
         .expect("template error");
 
-    (call_doc, event_doc)
+    // render errors
+    context.insert("error_counter", &error_counter);
+    let error_doc = tera
+        .render("runtime-errors.md", &context)
+        .expect("template error");
+
+    (call_doc, event_doc, error_doc)
 }
-- 
GitLab