RegisterMultiCauseEncoder can be used to register new multi-cause error types to the library. Registered types will be encoded using their own Go type when an error is encoded. Multi-cause wrappers that have not been registered will be encoded using the opaqueWrapper type.
(theType TypeKey, encoder MultiCauseEncoder)
| 358 | // that have not been registered will be encoded using the |
| 359 | // opaqueWrapper type. |
| 360 | func RegisterMultiCauseEncoder(theType TypeKey, encoder MultiCauseEncoder) { |
| 361 | // This implementation is a simple wrapper around `LeafEncoder` |
| 362 | // because we implemented multi-cause error wrapper encoding into a |
| 363 | // `Leaf` instead of a `Wrapper` for smoother backwards |
| 364 | // compatibility support. Exposing this detail to consumers of the |
| 365 | // API is confusing and hence avoided. The causes of the error are |
| 366 | // encoded separately regardless of this encoder's implementation. |
| 367 | RegisterLeafEncoder(theType, encoder) |
| 368 | } |
| 369 | |
| 370 | // MultiCauseEncoder is to be provided (via RegisterMultiCauseEncoder |
| 371 | // above) by additional multi-cause wrapper types not yet known to this |
searching dependent graphs…