cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Mgodby
Post Patron
Post Patron

How to do Try Catch in PowerApps on a AzureBlob Function Call

Hello. I am trying to do an Azure function call. This is the code:

 

codecausingissue.png

 

The issue is that sometimes it may attempt to delete a file that doesn't exist. I tried to use IsError and IfError to catch it when it fails but nothing works, it still labels itself a fail and doesn't do the catch I set for it.

 

Here is the IsError code:

This one doesn't seem to work, when I run it, I still get the same error message over the "GetFileMetadataByPath" function and it doesn't set the variables.

 

IsError.png

 

Same for IfError:

The variable does not get set at all and the "GetFileMetadataByPath" function still gives out an error but it is not caught.

 

IfError.png

 

Has anybody come across similar issues? Do you know how I can catch this error? Basically what I want is to try to delete but if it fails then move on. Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Mgodby ,

 

That's weird as this code works perfectly on my side. If the path isn't correct, the return id is blank. Where does it not meet your requirements? 

Please try with this code, and try to input the wrong and correct path to see the variable change.

If(IsBlank(AzureBlobStorage.GetFileMetadataByPath(AzureContainer & "1.jpg").Id),Set(varError, "Error"),Set(varError, "NoError"))

 

I also try The IfError function, but it doesn't seems recognize errors from the API.

Sik

View solution in original post

3 REPLIES 3
v-siky-msft
Community Support
Community Support

Hi @Mgodby ,

 

Please try to modify the code as follows.

If(IsBlank(AzureBlobStorage.GetFileMetadataByPath(AzureContainer & "1.jpg").Id),Set(varError, "Error"))

Hope this helps.

Sik 

Unfortunately no. I initially tried using IsBlank before IsError and IfError and it sill gives errors. 

Hi @Mgodby ,

 

That's weird as this code works perfectly on my side. If the path isn't correct, the return id is blank. Where does it not meet your requirements? 

Please try with this code, and try to input the wrong and correct path to see the variable change.

If(IsBlank(AzureBlobStorage.GetFileMetadataByPath(AzureContainer & "1.jpg").Id),Set(varError, "Error"),Set(varError, "NoError"))

 

I also try The IfError function, but it doesn't seems recognize errors from the API.

Sik

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (2,810)