diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-06 16:31:21 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-06 16:31:21 +0200 |
| commit | e2322eeb63efc492bbaf499427afd3592c4836be (patch) | |
| tree | f1e8de9fe95d55e2bec11fb7b5c2819033063ee5 /internal/flamegraph/counter.go | |
| parent | 96f30bc109818547e456251ad0c25e1e7308e22b (diff) | |
fix: return errors for unknown counter fields (task 383)
Diffstat (limited to 'internal/flamegraph/counter.go')
| -rw-r--r-- | internal/flamegraph/counter.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/internal/flamegraph/counter.go b/internal/flamegraph/counter.go index 539d017..441db68 100644 --- a/internal/flamegraph/counter.go +++ b/internal/flamegraph/counter.go @@ -28,17 +28,17 @@ func (c Counter) add(other Counter) Counter { return c } -func (c Counter) ValueByName(name string) uint64 { +func (c Counter) ValueByName(name string) (uint64, error) { switch name { case "count": - return c.Count + return c.Count, nil case "duration": - return c.Duration + return c.Duration, nil case "durationToPrev": - return c.DurationToPrev + return c.DurationToPrev, nil case "bytes": - return c.Bytes + return c.Bytes, nil default: - panic(fmt.Sprintln("No", name, "in count record")) + return 0, fmt.Errorf("unknown counter field %q", name) } } |
