mirror of
https://github.com/moby/buildkit.git
synced 2026-11-06 05:16:45 +00:00
lint: renable error types for errname
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
7 files changed
+26
-26
No files matched your search
+5
-5
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -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},
|
||||
})
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -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
|
||||
}
|
||||
Reference in new issue
Block a user