all: remove pkg/errors

This commit is contained in:
Ariel Mashraki
2021-08-05 16:32:15 +03:00
committed by Ariel Mashraki
parent f0710aa004
commit eb87d64980
21 changed files with 65 additions and 65 deletions

View File

@@ -5,10 +5,10 @@
package graphson
import (
"fmt"
"unsafe"
jsoniter "github.com/json-iterator/go"
"github.com/pkg/errors"
)
// EncoderOfError returns a value encoder which always fails to encode.
@@ -22,7 +22,7 @@ func (decodeExtension) DecoderOfError(format string, args ...interface{}) jsonit
}
func decoratorOfError(format string, args ...interface{}) errorCodec {
err := errors.Errorf(format, args...)
err := fmt.Errorf(format, args...)
return errorCodec{err}
}

View File

@@ -6,6 +6,7 @@ package graphson
import (
"bytes"
"errors"
"fmt"
"io"
"reflect"
@@ -13,7 +14,6 @@ import (
jsoniter "github.com/json-iterator/go"
"github.com/modern-go/reflect2"
"github.com/pkg/errors"
)
// DecoratorOfInterface decorates a value decoder of an interface type.
@@ -122,7 +122,7 @@ func (efaceDecoder) reflectType(typ Type) reflect2.Type {
func (efaceDecoder) reflectSlice(data []byte) (reflect2.Type, error) {
var elem interface{}
if err := Unmarshal(data, &[...]*interface{}{&elem}); err != nil {
return nil, errors.Wrap(err, "cannot read first list element")
return nil, fmt.Errorf("cannot read first list element: %w", err)
}
if elem == nil {
@@ -139,7 +139,7 @@ func (efaceDecoder) reflectMap(data []byte) (reflect2.Type, error) {
bytes.Replace(data, []byte(mapType), []byte(listType), 1),
&[...]*interface{}{&key, &elem},
); err != nil {
return nil, errors.Wrap(err, "cannot unmarshal first map item")
return nil, fmt.Errorf("cannot unmarshal first map item: %w", err)
}
if key == nil {

View File

@@ -5,12 +5,12 @@
package graphson
import (
"fmt"
"sync"
"unsafe"
jsoniter "github.com/json-iterator/go"
"github.com/modern-go/reflect2"
"github.com/pkg/errors"
)
// LazyEncoderOf returns a lazy encoder for type.
@@ -68,7 +68,7 @@ type uniqueType struct {
func (u *uniqueType) CheckType(other Type) error {
u.once.Do(func() { u.typ = other })
if u.typ != other {
return errors.Errorf("expect type %s, but found %s", u.typ, other)
return fmt.Errorf("expect type %s, but found %s", u.typ, other)
}
return u.elemChecker.CheckType(u.typ)
}

View File

@@ -11,7 +11,6 @@ import (
jsoniter "github.com/json-iterator/go"
"github.com/modern-go/reflect2"
"github.com/pkg/errors"
)
// DecoratorOfMarshaler decorates a value encoder of a Marshaler interface.
@@ -69,11 +68,11 @@ func (enc marshalerEncoder) Encode(ptr unsafe.Pointer, stream *jsoniter.Stream)
func (enc marshalerEncoder) encode(marshaler Marshaler, stream *jsoniter.Stream) {
data, err := marshaler.MarshalGraphson()
if err != nil {
stream.Error = errors.Wrapf(err, "graphson: error calling MarshalGraphson for type %s", enc.Type)
stream.Error = fmt.Errorf("graphson: error calling MarshalGraphson for type %s: %w", enc.Type, err)
return
}
if !config.Valid(data) {
stream.Error = errors.Errorf("graphson: syntax error when marshaling type %s", enc.Type)
stream.Error = fmt.Errorf("graphson: syntax error when marshaling type %s", enc.Type)
return
}
_, stream.Error = stream.Write(data)

View File

@@ -5,7 +5,7 @@
package graphson
import (
"github.com/pkg/errors"
"errors"
)
// RawMessage is a raw encoded graphson value.

View File

@@ -5,13 +5,13 @@
package graphson
import (
"fmt"
"io"
"reflect"
"unsafe"
jsoniter "github.com/json-iterator/go"
"github.com/modern-go/reflect2"
"github.com/pkg/errors"
)
// DecoratorOfSlice decorates a value encoder of a slice type.
@@ -87,7 +87,7 @@ type sliceDecoder struct {
func (dec sliceDecoder) Decode(ptr unsafe.Pointer, iter *jsoniter.Iterator) {
dec.decode(ptr, iter)
if iter.Error != nil && iter.Error != io.EOF {
iter.Error = errors.Wrapf(iter.Error, "decoding slice %s", dec.sliceType)
iter.Error = fmt.Errorf("decoding slice %s: %w", dec.sliceType, iter.Error)
}
}
@@ -119,7 +119,7 @@ type arrayDecoder struct {
func (dec arrayDecoder) Decode(ptr unsafe.Pointer, iter *jsoniter.Iterator) {
dec.decode(ptr, iter)
if iter.Error != nil && iter.Error != io.EOF {
iter.Error = errors.Wrapf(iter.Error, "decoding array %s", dec.arrayType)
iter.Error = fmt.Errorf("decoding array %s: %w", dec.arrayType, iter.Error)
}
}

View File

@@ -5,13 +5,13 @@
package graphson
import (
"fmt"
"reflect"
"strings"
"unsafe"
jsoniter "github.com/json-iterator/go"
"github.com/modern-go/reflect2"
"github.com/pkg/errors"
)
// A Type is a graphson type.
@@ -45,7 +45,7 @@ func (typ Type) String() string {
// CheckType implements typeChecker interface.
func (typ Type) CheckType(other Type) error {
if typ != other {
return errors.Errorf("expect type %s, but found %s", typ, other)
return fmt.Errorf("expect type %s, but found %s", typ, other)
}
return nil
}
@@ -80,7 +80,7 @@ func (types Types) String() string {
// CheckType implements typeChecker interface.
func (types Types) CheckType(typ Type) error {
if !types.Contains(typ) {
return errors.Errorf("expect any of %s, but found %s", types, typ)
return fmt.Errorf("expect any of %s, but found %s", types, typ)
}
return nil
}

View File

@@ -5,11 +5,11 @@
package graphson
import (
"errors"
"io"
"unsafe"
jsoniter "github.com/json-iterator/go"
"github.com/pkg/errors"
)
// graphson encoding type / value keys