slimtoolkit / slimtoolkit/slim

Better error messages

Open
#104 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Go
Stars
23.4k
Forks
840
PR merge metrics
No merged PRs in 30d

Description

Right now the error messages look like this:

time="2019-12-11T19:36:35-05:00" level=fatal msg="docker-slim: failure" error="json: cannot unmarshal array into Go value of type docker.Image" stack="goroutine 1 [running]:\nruntime/debug.Stack(0x0, 0x0, 0xc0004c7e01)\n\truntime/debug/stack.go:24 +0x9d\ngithub.com/docker-slim/docker-slim/pkg/util/errutil.FailOn(0xb6be20, 0xc000218050)\n\tgithub.com/docker-slim/docker-slim@/pkg/util/errutil/errutil.go:14 +0x54\ngithub.com/docker-slim/docker-slim/internal/app/master/commands.OnBuild(0x9c4e01, 0xa92aae, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, 0xa80000, 0xc0001bef90, ...)\n\tgithub.com/docker-slim/docker-slim@/internal/app/master/commands/build.go:178 +0x91d\ngithub.com/docker-slim/docker-slim/internal/app/master.init.0.func6(0xc0001c8160, 0x0, 0xc0001ce2b0)\n\tgithub.com/docker-slim/docker-slim@/internal/app/master/cli.go:775 +0x1709\ngithub.com/urfave/cli.HandleAction(0x9b03a0, 0xab7478, 0xc0001c8160, 0xc0001c8160, 0x0)\n\tgithub.com/urfave/cli@v1.22.1/app.go:523 +0xbe\ngithub.com/urfave/cli.Command.Run(0xa8978f, 0x5, 0x0, 0x0, 0xc00017a580, 0x1, 0x1, 0xaab688, 0x3e, 0x0, ...)\n\tgithub.com/urfave/cli@v1.22.1/command.go:174 +0x51c\ngithub.com/urfave/cli.(*App).Run(0xc00018c000, 0xc000084150, 0x3, 0x3, 0x0, 0x0)\n\tgithub.com/urfave/cli@v1.22.1/app.go:276 +0x718\ngithub.com/docker-slim/docker-slim/internal/app/master.runCli()\n\tgithub.com/docker-slim/docker-slim@/internal/app/master/cli.go:1159 +0x55\ngithub.com/docker-slim/docker-slim/internal/app/master.Run()\n\tgithub.com/docker-slim/docker-slim@/internal/app/master/app.go:6 +0x25\nmain.main()\n\tgithub.com/docker-slim/docker-slim@/cmd/docker-slim/main.go:8 +0x20\n" version="linux|Transformer|1.26.1|2ec04e169b12a87c5286aa09ef44eac1cea2c7a1|2019-11-28_04:37:59PM"

I would rather they looked like this:

time="2019-12-11T19:36:35-05:00" level=fatal msg="docker-slim: failure" error="json: cannot unmarshal array into Go value of type docker.Image" stack="goroutine 1 [running]:
runtime/debug.Stack(0x0, 0x0, 0xc0004c7e01)
	runtime/debug/stack.go:24 +0x9d
github.com/docker-slim/docker-slim/pkg/util/errutil.FailOn(0xb6be20, 0xc000218050)
	github.com/docker-slim/docker-slim@/pkg/util/errutil/errutil.go:14 +0x54
github.com/docker-slim/docker-slim/internal/app/master/commands.OnBuild(0x9c4e01, 0xa92aae, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, 0xa80000, 0xc0001bef90, ...)
	github.com/docker-slim/docker-slim@/internal/app/master/commands/build.go:178 +0x91d
github.com/docker-slim/docker-slim/internal/app/master.init.0.func6(0xc0001c8160, 0x0, 0xc0001ce2b0)
	github.com/docker-slim/docker-slim@/internal/app/master/cli.go:775 +0x1709
github.com/urfave/cli.HandleAction(0x9b03a0, 0xab7478, 0xc0001c8160, 0xc0001c8160, 0x0)
	github.com/urfave/cli@v1.22.1/app.go:523 +0xbe
github.com/urfave/cli.Command.Run(0xa8978f, 0x5, 0x0, 0x0, 0xc00017a580, 0x1, 0x1, 0xaab688, 0x3e, 0x0, ...)
	github.com/urfave/cli@v1.22.1/command.go:174 +0x51c
github.com/urfave/cli.(*App).Run(0xc00018c000, 0xc000084150, 0x3, 0x3, 0x0, 0x0)
	github.com/urfave/cli@v1.22.1/app.go:276 +0x718
github.com/docker-slim/docker-slim/internal/app/master.runCli()
	github.com/docker-slim/docker-slim@/internal/app/master/cli.go:1159 +0x55
github.com/docker-slim/docker-slim/internal/app/master.Run()
	github.com/docker-slim/docker-slim@/internal/app/master/app.go:6 +0x25
main.main()
	github.com/docker-slim/docker-slim@/cmd/docker-slim/main.go:8 +0x20
" version="linux|Transformer|1.26.1|2ec04e169b12a87c5286aa09ef44eac1cea2c7a1|2019-11-28_04:37:59PM"

It looks like a string isn't being formatted somewhere maybe?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in pkg/util/errutil/errutil.go at errutil.FailOn, then trace the call from internal/app/master/commands/build.go. Reproduce the reported failure and compare the emitted stack trace with the issue's desired formatting; done means the error output preserves the intended line breaks and indentation.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.