Skip to content

Commit

Permalink
[chore][pkg/ottl] Use type formatter instead of calling .Type()
Browse files Browse the repository at this point in the history
  • Loading branch information
evan-bradley committed May 20, 2024
1 parent f876d49 commit 1a0bdf5
Showing 1 changed file with 8 additions and 8 deletions.
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

0 comments on commit 1a0bdf5

Please sign in to comment.