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

worried-engineer-33884

06/25/2019, 7:16 PM
for a dynamic provider/resource, what do i return if i want
create
to fail?
e

early-musician-41645

06/25/2019, 7:18 PM
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

tall-librarian-49374

06/25/2019, 7:45 PM
c

clever-sunset-76585

06/27/2019, 2:16 PM
In fact, this is the way to let Pulumi know that a resource operation has failed; dynamic resource or not.
w

worried-engineer-33884

07/01/2019, 5:07 PM
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

clever-sunset-76585

07/01/2019, 5:48 PM
@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

worried-engineer-33884

07/01/2019, 6:04 PM
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

early-musician-41645

07/10/2019, 5:29 PM
From the little I know about callback idioms, I think you'd provide an error handler as an argument to the apply?