openshift / image-inspector

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

improve readability of errors with pkg/error

ilackarms opened this issue · comments

Currently the (anti-)pattern of

if err != nil {
     return nil, err
}

is replete through our repository. this pattern makes debugging errors very difficult when they occur, as we're not provided a stack trace or any context of where the original error occurred. for example, see https://bugzilla.redhat.com/show_bug.cgi?id=1486314 where the only error message we can see is error: unexpected EOF. Where did this EOF happen? Was it during a file download? Opening a file? Writing to disc? Extracting an archive?

I think it's an anti-pattern in go to bubble up errors without providing context for them. For this reason packages such as https://github.com/pkg/errors have been created so that lower-level errors can be wrapped before they are returned up the call stack.

I propose that we improve the debuggability of image-inspector by wrapping errors wherever they are returned, be it with pkg/error, fmt.Errorf("...: %v", err), or some other solution.

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

Stale issues rot after 30d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle rotten
/remove-lifecycle stale

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

Stale issues rot after 30d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle rotten
/remove-lifecycle stale

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Exclude this issue from closing again by commenting /lifecycle frozen.

/close

@openshift-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Exclude this issue from closing again by commenting /lifecycle frozen.

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.