https://pulumi.com logo
#general
Title
# general
v

victorious-continent-984

07/15/2022, 9:41 AM
Hi, wondering how I could stop pulumi preview or update when error occurred and handle exceptions however I want. Right now I just throw an exception, it does the work but I see:
error: Program failed with an unhandled exception:
, instead I want a short and clear message.
e

echoing-dinner-19531

07/15/2022, 10:02 AM
I thought we already had an issue about this, but I can only find https://github.com/pulumi/pulumi/issues/3364 which I don't think is exactly what your asking for. It's an interesting idea though.
v

victorious-continent-984

07/15/2022, 10:07 AM
Not quite. My scenario is the following. I’m developing a component that could build Docker images from remote repositories, to do that I should clone contents. But there could be some errors, like repo doesn’t exist, you lack permissions to access it etc. So right now I’m doing it like:
Copy code
pulumi.error('repo not found')
raise NameError("Repository {url} doesn't exist or you lack permissions.')
it stops the execution and shows the errors but says it has unhandled exceptions. And I see 4 errors instead of one.
What I want is to show a single error in a handled manner
and the code would look like:
Copy code
pulumi.error('repo not found')
pulumi.stop()
e

echoing-dinner-19531

07/15/2022, 10:09 AM
Gimme a minute, there might be a way to do this I'll go have a quick code splunk. If not this sounds like a reasonable feature request to make on github.
OK looks like there is not a way to do this right now. So do raise an request about it at https://github.com/pulumi/pulumi/issues it sounds reasonable.
v

victorious-continent-984

07/15/2022, 10:21 AM
e

echoing-dinner-19531

07/15/2022, 10:21 AM
Thanks! We'll take a look into this
🔥 1
6 Views