Skip to content

Conversation

@thaJeztah
Copy link

Check whether formatInfo or prettyPrintInfo handled the error, otherwise return it. Previously we'd print the error, but the function may not have handled the error if a template was used that didn't consume the ServerErrors field.

Before;

docker -H example.invalid info > /dev/null
ERROR: error during connect: Get "http://example.invalid:2375/v1.48/info": dial tcp: lookup example.invalid: no such host
errors pretty printing info
echo $?
1

docker -H example.invalid info --format '{{.Architecture}}' > /dev/null
error during connect: Get "http://example.invalid:2375/v1.48/info": dial tcp: lookup example.invalid: no such host

echo $?
0

# invalid template
docker -H example.invalid info --format '{{.Whoops}}' > /dev/null
error during connect: Get "http://example.invalid:2375/v1.48/info": dial tcp: lookup example.invalid: no such host
template: :1:2: executing "" at <.Whoops>: cant evaluate field Whoops in type system.dockerInfo
echo $?
1

After;

docker -H example.invalid info > /dev/null
ERROR: error during connect: Get "http://example.invalid:2375/v1.48/info": dial tcp: lookup example.invalid: no such host
errors pretty printing info

echo $?
1

docker -H example.invalid info --format '{{.Architecture}}' > /dev/null
error during connect: Get "http://example.invalid:2375/v1.48/info": dial tcp: lookup example.invalid: no such host

echo $?
1

docker -H example.invalid info --format '{{.Whoops}}' > /dev/null
error during connect: Get "http://example.invalid:2375/v1.48/info": dial tcp: lookup example.invalid: no such host
template: :1:2: executing "" at <.Whoops>: cant evaluate field Whoops in type system.dockerInfo

echo %?
1

- What I did

- How I did it

- How to verify it

- Human readable description for the release notes

- A picture of a cute animal (not mandatory but encouraged)

Benehiko and others added 2 commits March 10, 2025 14:26
Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
Check whether `formatInfo` or `prettyPrintInfo` handled the error, otherwise
return it. Previously we'd print the error, but the function may not have
handled the error if a template was used that didn't consume the ServerErrors
field.

Before;

    docker -H example.invalid info > /dev/null
    ERROR: error during connect: Get "http://example.invalid:2375/v1.48/info": dial tcp: lookup example.invalid: no such host
    errors pretty printing info
    echo $?
    1

    docker -H example.invalid info --format '{{.Architecture}}' > /dev/null
    error during connect: Get "http://example.invalid:2375/v1.48/info": dial tcp: lookup example.invalid: no such host

    echo $?
    0

    # invalid template
    docker -H example.invalid info --format '{{.Whoops}}' > /dev/null
    error during connect: Get "http://example.invalid:2375/v1.48/info": dial tcp: lookup example.invalid: no such host
    template: :1:2: executing "" at <.Whoops>: cant evaluate field Whoops in type system.dockerInfo
    echo $?
    1

After;

    docker -H example.invalid info > /dev/null
    ERROR: error during connect: Get "http://example.invalid:2375/v1.48/info": dial tcp: lookup example.invalid: no such host
    errors pretty printing info

    echo $?
    1

    docker -H example.invalid info --format '{{.Architecture}}' > /dev/null
    error during connect: Get "http://example.invalid:2375/v1.48/info": dial tcp: lookup example.invalid: no such host

    echo $?
    1

    docker -H example.invalid info --format '{{.Whoops}}' > /dev/null
    error during connect: Get "http://example.invalid:2375/v1.48/info": dial tcp: lookup example.invalid: no such host
    template: :1:2: executing "" at <.Whoops>: cant evaluate field Whoops in type system.dockerInfo

    echo %?
    1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants