• Kirill Smelkov's avatar
    golang, errors, fmt: Error chaining (C++/Pyx) · fd95c88a
    Kirill Smelkov authored
    Following errors model in Go, let's add support for errors to wrap other
    errors and to be inspected/unwrapped:
    
    - an error can additionally provide way to unwrap itself, if it
      implements errorWrapper interface;
    - errors.Unwrap(err) tries to extract wrapped error;
    - errors.Is(err) tests whether an item in error's chain matches target;
    - `fmt.errorf("... : %w", ... err)` is similar to `fmt.errorf("... : %s", ... err.c_str())`
      but resulting error, when unwrapped, will return err.
    
    Add C++ implementation for the above + tests.
    Python analogs will follow in the next patches.
    
    Top-level documentation is TODO.
    
    See https://blog.golang.org/go1.13-errors for error chaining overview.
    fd95c88a
fmt_test.cpp 4.11 KB