Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore][pkg/ottl] Use type formatter instead of calling .Type() #33130

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions pkg/ottl/expression.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func (g StandardStringGetter[K]) Get(ctx context.Context, tCtx K) (string, error
if v.Type() == pcommon.ValueTypeStr {
return v.Str(), nil
}
return "", TypeError(fmt.Sprintf("expected string but got %v", v.Type()))
return "", TypeError(fmt.Sprintf("expected string but got %T", v))
default:
return "", TypeError(fmt.Sprintf("expected string but got %T", val))
}
Expand Down Expand Up @@ -212,7 +212,7 @@ func (g StandardIntGetter[K]) Get(ctx context.Context, tCtx K) (int64, error) {
if v.Type() == pcommon.ValueTypeInt {
return v.Int(), nil
}
return 0, TypeError(fmt.Sprintf("expected int64 but got %v", v.Type()))
return 0, TypeError(fmt.Sprintf("expected int64 but got %T", v))
default:
return 0, TypeError(fmt.Sprintf("expected int64 but got %T", val))
}
Expand Down Expand Up @@ -247,7 +247,7 @@ func (g StandardFloatGetter[K]) Get(ctx context.Context, tCtx K) (float64, error
if v.Type() == pcommon.ValueTypeDouble {
return v.Double(), nil
}
return 0, TypeError(fmt.Sprintf("expected float64 but got %v", v.Type()))
return 0, TypeError(fmt.Sprintf("expected float64 but got %T", v))
default:
return 0, TypeError(fmt.Sprintf("expected float64 but got %T", val))
}
Expand Down Expand Up @@ -282,7 +282,7 @@ func (g StandardBoolGetter[K]) Get(ctx context.Context, tCtx K) (bool, error) {
if v.Type() == pcommon.ValueTypeBool {
return v.Bool(), nil
}
return false, TypeError(fmt.Sprintf("expected bool but got %v", v.Type()))
return false, TypeError(fmt.Sprintf("expected bool but got %T", v))
default:
return false, TypeError(fmt.Sprintf("expected bool but got %T", val))
}
Expand Down Expand Up @@ -360,7 +360,7 @@ func (g StandardPMapGetter[K]) Get(ctx context.Context, tCtx K) (pcommon.Map, er
if v.Type() == pcommon.ValueTypeMap {
return v.Map(), nil
}
return pcommon.Map{}, TypeError(fmt.Sprintf("expected pcommon.Map but got %v", v.Type()))
return pcommon.Map{}, TypeError(fmt.Sprintf("expected pcommon.Map but got %T", v))
case map[string]any:
m := pcommon.NewMap()
err = m.FromRaw(v)
Expand Down Expand Up @@ -477,7 +477,7 @@ func (g StandardFloatLikeGetter[K]) Get(ctx context.Context, tCtx K) (*float64,
result = float64(0)
}
default:
return nil, TypeError(fmt.Sprintf("unsupported value type: %v", v.Type()))
return nil, TypeError(fmt.Sprintf("unsupported value type: %T", v))
}
default:
return nil, TypeError(fmt.Sprintf("unsupported type: %T", v))
Expand Down Expand Up @@ -541,7 +541,7 @@ func (g StandardIntLikeGetter[K]) Get(ctx context.Context, tCtx K) (*int64, erro
result = int64(0)
}
default:
return nil, TypeError(fmt.Sprintf("unsupported value type: %v", v.Type()))
return nil, TypeError(fmt.Sprintf("unsupported value type: %T", v))
}
default:
return nil, TypeError(fmt.Sprintf("unsupported type: %T", v))
Expand Down Expand Up @@ -599,7 +599,7 @@ func (g StandardBoolLikeGetter[K]) Get(ctx context.Context, tCtx K) (*bool, erro
case pcommon.ValueTypeDouble:
result = v.Double() != 0.0
default:
return nil, TypeError(fmt.Sprintf("unsupported value type: %v", v.Type()))
return nil, TypeError(fmt.Sprintf("unsupported value type: %T", v))
}
default:
return nil, TypeError(fmt.Sprintf("unsupported type: %T", val))
Expand Down
Loading