Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
error codes: add hierarchy Hierarchy is useful for documentation/classification purposes. The hierarchy can also be traversed to find find meta data on ancestors. This is now used in the HTTP Code implementation to inherit HTTP codes. Note that Previously HTTP codes were specified on the go error type, which doesn't make sense. Now HTTP codes are attached to an errcode.Code value via metadata. Previously I had already created error codes strings with a dot separation hiearchy. However, that was informal. Now that relationship is validated and modeled in code. The API still involves giving a dot separated hierachy. This requires some simple trivial parsing/validation in the implementation but made for a nicer API than specifying a struct with a parent link. Some inspiration here was taken from the upspin error codes which are classified by Kind. When I started adding kinds, I realized I just wanted to represent them as Codes, which naturally led to hierarchy. Kind classification can be though of as having many error hierarchies with a depth of two and a high branching factor. In our implementation the top level of the hierarchy can be used like a kind, but we can also create as much or little depth in the tree as we would like. https://commandcenter.blogspot.com/2017/12/error-handling-in-upspin.htm * simpler representation for metadata * allow just the child component of the code * errcode: change CodeStr to a method This makes it possible to change the storage format. In particular redundant versus relying on parent traversal * errcode: don't store the parent code on the child Its not supported now, but this would would make it possible to define children first and then define an ancestor. It also reduces redundant memory usage a little.
- Loading branch information