mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 22:37:14 +08:00
5a186d390f
This builds on top of recently introduced fscommon.ParseError. Errors returned from parsers (mostly ones used by GetStats()) are all different, and many are incomplete. For example, in many cases errors from strconv.ParseUint are returned as is, meaning there is no context telling which file we were reading. Similarly, errors from fscommon.ParseKeyValue should be wrapped to add more context. Same is true for scanner.Err(). One special case that repeats a few times is "malformed line: xxx". Add and use a helper for that to simplify things. OTOH, errors from fscommon.GetCgroup* do have enough context and there is no need to wrap them. Fix all the above. While at it, add a missing scanner.Err() check. [v2: use parseError not ParseError] Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
16 lines
407 B
Go
16 lines
407 B
Go
package fs
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/opencontainers/runc/libcontainer/cgroups/fscommon"
|
|
)
|
|
|
|
type parseError = fscommon.ParseError
|
|
|
|
// malformedLine is used by all cgroupfs file parsers that expect a line
|
|
// in a particular format but get some garbage instead.
|
|
func malformedLine(path, file, line string) error {
|
|
return &parseError{Path: path, File: file, Err: fmt.Errorf("malformed line: %s", line)}
|
|
}
|