web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Error Handling - Unabl...
Power Apps
Unanswered

Error Handling - Unable to force an error...

(0) ShareShare
ReportReport
Posted on by 22
Hi. I have a strange question as I actually want to see an error!
 
I'm experimenting with error handling and wanted to use application-wide OnError to include code to add a Trace to the Monitor and also store errors in an event log. I found code and adapted to suit.
 
However, I'm unable to actually test this code as for some reason my app is not throwing an error! I've tried a basic form and added text box controls that force a divide by zero calculation but this doesn't actually throw an error. The 'result' is simply blank and no error is being displayed or logged. No error appears in the monitor. Same behaviour if I try to force a numerical calculation to textbox inputs that are merely text not numbers. This should throw an error.
 
Same behaviour if I delete all code from OnError. No apparent error handling is in place and yet no error message is shown. I'm really not sure what's happening. Any suggestions? Or other ideas for things I can try to force an error?
 
Thanks!
Categories:
I have the same question (0)
  • mmbr1606 Profile Picture
    14,605 Super User 2025 Season 2 on at
    well if you are looking to produce an error you can try something like:
    Patch(DataSource, Defaults(DataSource), {NonExistentColumn: "SomeValue"})
    
    if my answer helped please mark as verified answer
     
     
    cheers
  • newbieappdeveloper Profile Picture
    22 on at
    Thanks but not even that gives me an error. (It shows as a formula error in the App checker, but is not throwing a runtime error when I apply it to the OnSelect function of a button.)
  • mmbr1606 Profile Picture
    14,605 Super User 2025 Season 2 on at
    what else u can try is
     
    Patch(
        SharePointListName,            
        Defaults(SharePointListName),   
        {
            TextColumnName: TextInput1  
        }
    )
    
    this should give u an errror, i dont know if you can work with it for your use case
     
     
    cheers
  • newbieappdeveloper Profile Picture
    22 on at
    It's still not creating a runtime error
  • mmbr1606 Profile Picture
    14,605 Super User 2025 Season 2 on at
    Not on my Maschine right now so cant test If IT creates a runtime Error but can u try this
     
    Label.Text = 1 / 0
     
    Cheers
  • timl Profile Picture
    36,411 Super User 2025 Season 2 on at
    Hi  CU24101045-0 
     
    The runtime errors that you're looking to reproduce will occur only if the errors are raised during execution at runtime.
     
    Let's say you set a label text to "1/0" or Patch a non existent column. Since these errors are 'statically' there and haven't been triggered through an end-user interaction or runtime process, those errors will not be raised (which is what you're seeing).
     
    Let's say you add 2 text input controls txtDividend and txtDivisor, and set the initial values of these to 1.
     
    Next, add a label and set the text property to txtDividend.Text/txtDivisor.Text.
     
    If you now run the app and type 0 into the txtDivisor text input control, the 'divide by 0' error should then be raised.
     
    Another thing to note is that errors that occur in Set won't be raised unless the result is used. For example, this won't raise an error when you enter 0 into txtDivisor.
     
    Set(varResult, txtDividend.Text/txtDivisor.Text)
     
    However, it will be raised if there's a label on your screen with the text property set to varResult.
      
  • newbieappdeveloper Profile Picture
    22 on at
    Thanks timl.
     
    I've tried this when 'playing' the app in development and also when playing a published version of the app. Still no error being generated with the scenario you've described (setting up text input controls, setting up a label control which calculates a division of those text input controls and then entering '0' into them).
     
    I'm very confused! There seems to be no way to force an error so no way for me to test my error handling code.
  • timl Profile Picture
    36,411 Super User 2025 Season 2 on at
    Hi  CU24101045-0
     
    Thanks for the update. That's very strange as I can recreate that scenario.
     
    To diagnose this, could you try creating a brand new app with that scenario  (setting up text input controls, setting up a label control which calculates a division of those text input controls and then entering '0' into them) and leaving the App > OnError property completely empty?

    This would at least rule out any setting or ambiguity in your existing that that prevents this from working. 
      
  • newbieappdeveloper Profile Picture
    22 on at
    Hi timl.
     
    I started a fresh application and inserted the exact same controls and with this fresh app it DOES produce the error at runtime for divide by zero. So there's something strange happening in my original app. Is there a setting somewhere that I should look at?
  • timl Profile Picture
    36,411 Super User 2025 Season 2 on at
    Hi CU24101045-0
     
    In your original app, are you handling errors with code in the OnError property? If so, the error that's thrown should  be caught there and the error message will not show. 

    If you have code in OnError and you want the error message to display, you'll need to rethrow the error.
     
    //Do stuff with the error 
    //eg Patch it, send email, etc
    Error(AllErrors)
      
    If you want to handle divide by 0 errors (which is of error type 13), and display all other errors, the code would look something like this.
     
    
    If(Last(AllErrors).Kind = 13,
       //Handle divide by 0 error in your own way,
       Error(AllErrors)
    )
    
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard