Skip to content

Commit

Permalink
[Self-service error codes] Error code definitions revisiting [DPP-675] (
Browse files Browse the repository at this point in the history
#11686)

* Error definitions revisiting and hierarchical grouping refactoring

CHANGELOG_BEGIN
CHANGELOG_END

* Full hierarchical path for error grouping

* Addressed Pawel's review comments

* Apply suggestions from code review

Co-authored-by: mziolekda <[email protected]>
Co-authored-by: pbatko-da <[email protected]>

* Do not strip margin in error code explanations

* Revert changing LEDGER_ID_MISMATCH from NOT_FOUND to FAILED_PRECONDITION

Co-authored-by: mziolekda <[email protected]>
Co-authored-by: pbatko-da <[email protected]>
  • Loading branch information
3 people authored Nov 15, 2021
1 parent a1fc5c6 commit ec6d7cc
Show file tree
Hide file tree
Showing 48 changed files with 900 additions and 1,095 deletions.
14 changes: 9 additions & 5 deletions docs/sphinx_ext/self_service_error_codes_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def build_hierarchical_tree_of_error_data(data) -> defaultdict:

# DFS to traverse the error code data tree from `build_hierarchical_tree_of_error_data`
# While traversing the tree, the presentation of the error codes on the documentation is built
def dfs(tree, node, prefix: str) -> None:
def dfs(tree, node, numeric_prefix: str, topic_prefix: str) -> None:
if 'explanation' in tree and tree['explanation']:
node += group_explanation_to_node(tree['explanation'])
if 'error-codes' in tree:
Expand All @@ -140,10 +140,14 @@ def dfs(tree, node, prefix: str) -> None:
for subtopic, subtree in tree.items():
if subtopic in ['error-codes', 'explanation']:
continue
subprefix = f"{prefix}{i}."
subtree_node_numeric_prefix = f"{numeric_prefix}{i}."
i += 1
subtree_node = text_node(n=nodes.rubric, txt = subprefix + " " + subtopic)
dfs(tree=subtree, node=subtree_node, prefix=subprefix)
topic = subtopic
if topic_prefix != "":
topic = topic_prefix + " / " + subtopic
subtree_node_header = subtree_node_numeric_prefix + " " + topic
subtree_node = text_node(n=nodes.rubric, txt = subtree_node_header)
dfs(tree=subtree, node=subtree_node, numeric_prefix=subtree_node_numeric_prefix, topic_prefix=topic)
node += subtree_node

for node in doctree.traverse(error_code_node):
Expand All @@ -155,7 +159,7 @@ def dfs(tree, node, prefix: str) -> None:
root = nodes.rubric(rawsource = "", text = "")
section += root
tree = build_hierarchical_tree_of_error_data(data=error_codes_data.values())
dfs(tree=tree, node=root, prefix="")
dfs(tree=tree, node=root, numeric_prefix="", topic_prefix="")
node.replace_self(new=[section])


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,15 @@ package com.daml.error.definitions
import com.daml.error.{ErrorClass, ErrorGroup}

object ErrorGroups {
val rootErrorClass: ErrorClass = ErrorClass.root()

private implicit val errorClass: ErrorClass = ErrorClass.root()

object ParticipantErrorGroup extends ErrorGroup() {
object ParticipantErrorGroup extends ErrorGroup()(rootErrorClass) {
abstract class IndexErrorGroup extends ErrorGroup() {
abstract class DatabaseErrorGroup extends ErrorGroup()
}
abstract class PackageServiceErrorGroup extends ErrorGroup()
abstract class PruningServiceErrorGroup extends ErrorGroup()
object TransactionErrorGroup extends ErrorGroup() {
// Errors emitted by Ledger Api server
abstract class LedgerApiErrorGroup extends ErrorGroup()
// TransactionSubmissionErrors are routing errors resulting from the transaction processor
abstract class SubmissionErrorGroup extends ErrorGroup()
abstract class LedgerApiErrorGroup extends ErrorGroup() {
abstract class CommandExecutionErrorGroup extends ErrorGroup()
abstract class PackageServiceErrorGroup extends ErrorGroup()
}
}
}
Loading

0 comments on commit ec6d7cc

Please sign in to comment.