libcontainer: don't double-quote errors
genericError.Error() was formatting the underlying error using `%q`; as a result, quotes in underlying errors were escaped multiple times, which caused the output to become hard to read, for example (wrapped for readability): ``` container_linux.go:345: starting container process caused "process_linux.go:430: container init caused \"rootfs_linux.go:58: mounting \\\"/foo.txt\\\" to rootfs \\\"/var/lib/docker/overlay2/f49a0ae0ec6646c818dcf05dbcbbdd79fc7c42561f3684fbb1fc5d2b9d3ad192/merged\\\" at \\\"/var/lib/docker/overlay2/f49a0ae0ec6646c818dcf05dbcbbdd79fc7c42561f3684fbb1fc5d2b9d3ad192/merged/usr/share/nginx/html\\\" caused \\\"not a directory\\\"\"": unknown ``` With this patch applied: ``` container_linux.go:348: starting container process caused: process_linux.go:438: container init caused: rootfs_linux.go:58: mounting "/foo.txt" to rootfs "/var/lib/docker/overlay2/de506d67da606b807009e23b548fec60d72359c77eec88785d8c7ecd54a6e4b2/merged" at "/var/lib/docker/overlay2/de506d67da606b807009e23b548fec60d72359c77eec88785d8c7ecd54a6e4b2/merged/usr/share/nginx/html" caused: not a directory: unknown ``` Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
dd8d48ede8
commit
2adfd20ac9
|
@ -80,7 +80,7 @@ func (e *genericError) Error() string {
|
||||||
return e.Message
|
return e.Message
|
||||||
}
|
}
|
||||||
frame := e.Stack.Frames[0]
|
frame := e.Stack.Frames[0]
|
||||||
return fmt.Sprintf("%s:%d: %s caused %q", frame.File, frame.Line, e.Cause, e.Message)
|
return fmt.Sprintf("%s:%d: %s caused: %s", frame.File, frame.Line, e.Cause, e.Message)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *genericError) Code() ErrorCode {
|
func (e *genericError) Code() ErrorCode {
|
||||||
|
|
Loading…
Reference in New Issue