Is there any plan to introduce custom exceptions f...
# python
g
Is there any plan to introduce custom exceptions for pulumi? I just noticed that
runtime.invoke
raises
Exception
which is not a good practice in python and one should use custom exceptions, so at least raising
PulumiError
or something would be great. https://github.com/pulumi/pulumi/blob/master/sdk/python/lib/pulumi/runtime/invoke.py#L121 @red-match-15116 Is there any chance that there is an existing issue about this? (I could not find any) I bumped into this trying to get an existing RDS instance when I found out that the
classic
AWS provider differentiates between 2 types and I'm only interested in arguments that they have in common.
Copy code
try:
    db = rds.get_cluster(
        cluster_identifier=db_params.apply(lambda x: x["db"]["identifier"]),
        opts=pulumi.InvokeOptions(provider=ec1_provider),
    )
except Exception as exc:
    print(type(exc))
    db = rds.get_instance(
        db_instance_identifier=db_params.apply(lambda x: x["db"]["identifier"]),
        opts=pulumi.InvokeOptions(provider=ec1_provider),
    )
AWS SDK in this case raises
DBClusterNotFoundFault
but I guess that
pulumi.runtime.invoke
is not smart enough to raise this exception.
r
Hey! I don’t believe there’s an issue for this and it’s not currently on the roadmap. Feel free to open an issue.
👍 1