Commit cb94be39 authored by Kirill Smelkov's avatar Kirill Smelkov

go/*: Add Unwrap to custom errors that have Cause

So that Go1.13 and golang.org/x/xerrors understand the wrapping:
https://blog.golang.org/go1.13-errors

Preserve Cause for compatibility with github.com/pkg/errors.
parent eccf827f
// Copyright (C) 2016-2018 Nexedi SA and Contributors.
// Copyright (C) 2016-2020 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
......@@ -1282,7 +1282,9 @@ func (e *ConnError) Error() string {
}
func (e *LinkError) Cause() error { return e.Err }
func (e *LinkError) Unwrap() error { return e.Err }
func (e *ConnError) Cause() error { return e.Err }
func (e *ConnError) Unwrap() error { return e.Err }
func (nl *NodeLink) err(op string, e error) error {
if e == nil {
......
// Copyright (C) 2017-2019 Nexedi SA and Contributors.
// Copyright (C) 2017-2020 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
......@@ -96,9 +96,8 @@ type RecordError struct {
Err error // actual error
}
func (e *RecordError) Cause() error {
return e.Err
}
func (e *RecordError) Cause() error { return e.Err }
func (e *RecordError) Unwrap() error { return e.Err }
func (e *RecordError) Error() string {
// XXX omit path: when .Err already contains it (e.g. when it is os.PathError)?
......
// Copyright (C) 2016-2019 Nexedi SA and Contributors.
// Copyright (C) 2016-2020 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
......@@ -315,9 +315,8 @@ func (e *OpError) Error() string {
return s
}
func (e *OpError) Cause() error {
return e.Err
}
func (e *OpError) Cause() error { return e.Err }
func (e *OpError) Unwrap() error { return e.Err }
// IStorage is the interface provided by opened ZODB storage.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment