for a dynamic provider/resource, what do i return ...
# general
w
for a dynamic provider/resource, what do i return if i want
create
to fail?
e
I've seen these fail just by throwing errors
👌 1
e.g. I was doing a POST to a rest api and it threw an auth error that showed up as a failed resource
t
c
In fact, this is the way to let Pulumi know that a resource operation has failed; dynamic resource or not.
w
is there a way to test for throwing an error in an apply callback? e.g.
Copy code
const foo = someOutput.apply(value => {
    throw new Error("this will never resolve");
})
how would i assert the error or failure in my mocha tests?
c
@worried-engineer-33884 hmm I am not sure how you could test if an error is thrown inside an
apply
. Have you looked at the blog post Joe did on unit testing? https://blog.pulumi.com/testing-your-infrastructure-as-code-with-pulumi …not sure if you did already, but perhaps something in there might provide a hint to something you could try.
w
I did read that blog post — I've based our tests on that — but did not find anything on catching errors thrown in apply
e
From the little I know about callback idioms, I think you'd provide an error handler as an argument to the apply?