From 4e8334de7504af335ec459b8c96a5843d2c789e7 Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Thu, 1 May 2025 20:35:29 -0700 Subject: [PATCH] lint: renable error types for errname Signed-off-by: Tonis Tiigi --- errdefs/internal.go | 10 +++++----- frontend/dockerfile/builder/build.go | 2 +- frontend/dockerfile/dockerfile2llb/convert.go | 2 +- frontend/dockerfile/parser/errors.go | 10 +++++----- solver/errdefs/source.go | 12 ++++++------ util/grpcerrors/grpcerrors.go | 8 ++++---- util/stack/stack.go | 8 ++++---- 7 files changed, 26 insertions(+), 26 deletions(-) diff --git a/errdefs/internal.go b/errdefs/internal.go index 24cea7e33..bf03d0f99 100644 --- a/errdefs/internal.go +++ b/errdefs/internal.go @@ -5,13 +5,13 @@ import ( "syscall" ) -type internalErr struct { +type internalError struct { error } -func (internalErr) System() {} +func (internalError) System() {} -func (err internalErr) Unwrap() error { +func (err internalError) Unwrap() error { return err.error } @@ -19,13 +19,13 @@ type system interface { System() } -var _ system = internalErr{} +var _ system = internalError{} func Internal(err error) error { if err == nil { return nil } - return internalErr{err} + return internalError{err} } func IsInternal(err error) bool { diff --git a/frontend/dockerfile/builder/build.go b/frontend/dockerfile/builder/build.go index ed5bccc0b..26b019df4 100644 --- a/frontend/dockerfile/builder/build.go +++ b/frontend/dockerfile/builder/build.go @@ -103,7 +103,7 @@ func Build(ctx context.Context, c client.Client) (_ *client.Result, err error) { } defer func() { - var el *parser.ErrorLocation + var el *parser.LocationError if errors.As(err, &el) { for _, l := range el.Locations { err = wrapSource(err, src.SourceMap, l) diff --git a/frontend/dockerfile/dockerfile2llb/convert.go b/frontend/dockerfile/dockerfile2llb/convert.go index eed63b887..caf4a6c1e 100644 --- a/frontend/dockerfile/dockerfile2llb/convert.go +++ b/frontend/dockerfile/dockerfile2llb/convert.go @@ -137,7 +137,7 @@ func DockerfileLint(ctx context.Context, dt []byte, opt ConvertOpt) (*lint.LintR _, err := toDispatchState(ctx, dt, opt) - var errLoc *parser.ErrorLocation + var errLoc *parser.LocationError if err != nil { buildErr := &lint.BuildError{ Message: err.Error(), diff --git a/frontend/dockerfile/parser/errors.go b/frontend/dockerfile/parser/errors.go index 08a40c5d4..b3bcf2ae8 100644 --- a/frontend/dockerfile/parser/errors.go +++ b/frontend/dockerfile/parser/errors.go @@ -5,14 +5,14 @@ import ( "github.com/pkg/errors" ) -// ErrorLocation gives a location in source code that caused the error -type ErrorLocation struct { +// LocationError gives a location in source code that caused the error +type LocationError struct { Locations [][]Range error } // Unwrap unwraps to the next error -func (e *ErrorLocation) Unwrap() error { +func (e *LocationError) Unwrap() error { return e.error } @@ -45,7 +45,7 @@ func setLocation(err error, location []Range, add bool) error { if err == nil { return nil } - var el *ErrorLocation + var el *LocationError if errors.As(err, &el) { if add { el.Locations = append(el.Locations, location) @@ -54,7 +54,7 @@ func setLocation(err error, location []Range, add bool) error { } return err } - return stack.Enable(&ErrorLocation{ + return stack.Enable(&LocationError{ error: err, Locations: [][]Range{location}, }) diff --git a/solver/errdefs/source.go b/solver/errdefs/source.go index a1e7dc95f..290ed06db 100644 --- a/solver/errdefs/source.go +++ b/solver/errdefs/source.go @@ -14,25 +14,25 @@ func WithSource(err error, src *Source) error { if err == nil { return nil } - return &ErrorSource{Source: src, error: err} + return &SourceError{Source: src, error: err} } -type ErrorSource struct { +type SourceError struct { *Source error } -func (e *ErrorSource) Unwrap() error { +func (e *SourceError) Unwrap() error { return e.error } -func (e *ErrorSource) ToProto() grpcerrors.TypedErrorProto { +func (e *SourceError) ToProto() grpcerrors.TypedErrorProto { return e.Source } func Sources(err error) []*Source { var out []*Source - var es *ErrorSource + var es *SourceError if errors.As(err, &es) { out = Sources(es.Unwrap()) out = append(out, es.CloneVT()) @@ -41,7 +41,7 @@ func Sources(err error) []*Source { } func (s *Source) WrapError(err error) error { - return &ErrorSource{error: err, Source: s} + return &SourceError{error: err, Source: s} } func (s *Source) Print(w io.Writer) error { diff --git a/util/grpcerrors/grpcerrors.go b/util/grpcerrors/grpcerrors.go index adcce39a2..8689dfff0 100644 --- a/util/grpcerrors/grpcerrors.go +++ b/util/grpcerrors/grpcerrors.go @@ -139,7 +139,7 @@ func Code(err error) codes.Code { } func WrapCode(err error, code codes.Code) error { - return &withCode{error: err, code: code} + return &withCodeError{error: err, code: code} } func AsGRPCStatus(err error) (*status.Status, bool) { @@ -237,16 +237,16 @@ func (e *grpcStatusError) GRPCStatus() *status.Status { return e.st } -type withCode struct { +type withCodeError struct { code codes.Code error } -func (e *withCode) Code() codes.Code { +func (e *withCodeError) Code() codes.Code { return e.code } -func (e *withCode) Unwrap() error { +func (e *withCodeError) Unwrap() error { return e.error } diff --git a/util/stack/stack.go b/util/stack/stack.go index 458a1a781..68d73a458 100644 --- a/util/stack/stack.go +++ b/util/stack/stack.go @@ -85,7 +85,7 @@ func Enable(err error) error { } func Wrap(err error, s *Stack) error { - return &withStack{stack: s, error: err} + return &withStackError{stack: s, error: err} } func hasLocalStackTrace(err error) bool { @@ -173,15 +173,15 @@ func convertStack(s errors.StackTrace) *Stack { return &out } -type withStack struct { +type withStackError struct { stack *Stack error } -func (e *withStack) Unwrap() error { +func (e *withStackError) Unwrap() error { return e.error } -func (e *withStack) StackTrace() *Stack { +func (e *withStackError) StackTrace() *Stack { return e.stack }