Skip to content

Python: Improve error messages - #3825

Merged
helderco merged 6 commits into
dagger:mainfrom
KGB33:sdk-python-improve-error-messages
Nov 16, 2022
Merged

helderco merged 6 commits into
dagger:mainfrom
KGB33:sdk-python-improve-error-messages

Conversation

@KGB33

@KGB33 KGB33 commented Nov 14, 2022

Copy link
Copy Markdown
Contributor

Improves error messages when dagger is not installed or not running.

Also creates the catch all (DaggerExecption) mentioned in #3805.

Discord thread: https://discord.com/channels/707636530424053791/1041044357345718282/1041044783155654766

Message examples (Tracebacks removed)

Docker not installed

Before

FileNotFoundError: [Errno 2] No such file or directory: 'docker'

After

dagger.connectors.docker.ProvisionError: Command 'docker' not found.

Docker not running (Dagger Engine not cached)

Before

dagger.connectors.docker.ProvisionError: Failed to copy engine session binary: None

After

dagger.connectors.docker.ProvisionError: Failed to copy engine session binary: docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'.

Docker not running (Dagger Engine cached)

Before

ValueError: invalid literal for int() with base 10: ''

After

dagger.exceptions.DaggerException: Error: failed to run container: docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.

@KGB33 KGB33 changed the title Sdk Python: Improve error messages Python: Improve error messages Nov 14, 2022
Changed currently defined exceptions to inherit from DaggerException.

Signed-off-by: Kelton Bassingthwaite <[email protected]>
@KGB33
KGB33 force-pushed the sdk-python-improve-error-messages branch from 17429b2 to 2e82584 Compare November 14, 2022 22:48
@mircubed
mircubed requested a review from helderco November 14, 2022 23:04

@sipsma sipsma left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left one comment and need Helder to review the python-aspects of the code but the general idea looks great to me, greatly appreciated!

@helderco helderco left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this @KGB33, it's an improvement for sure!

It needs tests but I can deal with it in #3811.

@KGB33

KGB33 commented Nov 15, 2022

Copy link
Copy Markdown
Contributor Author

Thanks for cleaning it up for me!

I'd be happy to take a stab at some tests over the next few days (either in this PR or anther).

Signed-off-by: Kelton Bassingthwaite <[email protected]>
@helderco

helderco commented Nov 16, 2022 •

Copy link
Copy Markdown
Contributor

Thanks @KGB33, I'm going to merge as I'm going to need this. Feel free to add tests in a follow up PR 🙂

@helderco
helderco merged commit 59a34e5 into dagger:main Nov 16, 2022
@KGB33
KGB33 deleted the sdk-python-improve-error-messages branch November 16, 2022 17:52
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.

3 participants