Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested answer

Portal - How to test my custom error

(2) ShareShare
ReportReport
Posted on by 9

Hi everyone, 

I have followed this article to setup a custom error for my portal, this is what I had done:

1. Go to Portal Actions > Enable custom errors.

2. Go to Portal Management > Content Snippets > Create a new snippet named Portal Generic Error using my custom HTML.

pastedimage1592559413693v1.png

Now, I want to test if my custom error is working and showing correctly.

However, I don't know how to create an error for testing purpose of this custom error.

Can anyone help me to break my portal for testing my custom error message?

Thank you and best regards,

Adrian Nguyen

  • Suggested answer
    Daivat Vartak (v-9davar) Profile Picture
    7,336 Super User 2025 Season 1 on at
    Portal - How to test my custom error
    Hello Adrian,
     

    You've correctly set up the custom error handling for your Power Apps portal. Now, you need a way to force an error to trigger the display of your "Portal Generic Error" content snippet.

    Here's how you can create an error for testing purposes:

    1. Using Web Page Access Control Rules (Simplest):

    • Create a Restrictive Rule:

      • Go to Portal Management > Web Page Access Control Rules.
      • Create a new rule.
      • Set the Website to your portal.
      • Set the Web Page to a page you want to test (e.g., your home page or a specific page).
      • Set the Right to "Read".
      • Under Web Roles, leave it blank (meaning no roles have access).
      • Save the rule. 

    • Test:

      • Open your portal in an incognito/private browser session (to avoid any cached logins).
      • Navigate to the page you specified in the rule.
      • Since no roles have access, you should see your custom "Portal Generic Error" message.

      Explanation: This method forces an authorization error because no user (including anonymous) is allowed to read the page.

    2. Using Liquid Template Errors (More Technical):

    • Find a Liquid Template:

       

      • Locate a page template or content snippet that uses Liquid code.

    • Introduce an Error:

       

      • Add some incorrect Liquid code to the template. For example:

        • {{ unknown_variable }} (references a non-existent variable)
        • {{ page | invalid_filter }} (uses an invalid filter)
        • {% if page.unknown_property %} (accesses a non-existent property)  

    • Test:

       

      • Navigate to the page where you modified the Liquid code.
      • You should see your custom "Portal Generic Error" message.

      Explanation: Liquid errors are caught by the portal's error handling and will trigger the generic error page.

    3. Using JavaScript Errors (If Applicable):

    • Add JavaScript to a Page:

       

      • If your page has custom JavaScript, add a line that will cause an error:

        • undefined_variable.property; (accesses a property of an undefined variable)
        • throw new Error("Test Error"); (throws a custom error)  

    • Test:

      • Open the page in your browser.
      • Open the browser's developer console (F12).
      • Trigger the JavaScript error (e.g., by clicking a button that executes the bad code).
      • You might see the JavaScript error in the console, but the portal's custom error page should also be displayed.

      Explanation: JavaScript errors can sometimes be caught by the portal's error handling, especially if they occur during the page's initial rendering.

    Important Notes:

    • Clear Cache: After making changes, clear your portal's cache (using the "Clear cache" option in the portal admin toolbar).
    • Incognito/Private Browser: Use an incognito/private browser to ensure you're not seeing cached content or logged-in user behavior.
    • Debugging: If your custom error message isn't showing up, double-check the "Portal Generic Error" content snippet for typos or incorrect HTML.
    • Real Errors: Remember that these are forced errors for testing. Real errors in your portal should be addressed to prevent them from happening in production.

    •  

    By using these methods, you should be able to trigger your custom error message and verify that it's working as expected. Choose the method that best fits your testing needs and technical comfort level.

     
    If my answer was helpful, please click Like, and if it solved your problem, please mark it as verified to help other community members find more. If you have further questions, please feel free to contact me.
     
    My response was crafted with AI assistance and tailored to provide detailed and actionable guidance for your Microsoft Dynamics 365 query.
     
    Regards,
    Daivat Vartak
  • Suggested answer
    CU28030558-0 Profile Picture
    2 on at
    Portal - How to test my custom error
    Disabling the Web Template - Template worked for me.
  • Suggested answer
    Bipin D365 Profile Picture
    28,981 Moderator on at
    RE: Portal - How to test my custom error

    HI,

    If your problem is resolved, mark this thread verified so that it will be helpful for other community members.

    If found helpful, Please mark my answer verified.

  • Suggested answer
    Adrian Nguyen Profile Picture
    9 on at
    RE: Portal - How to test my custom error

    Found a way to break my portal: Add any html tag (example <p>) into an entity form and submit.

  • Adrian Nguyen Profile Picture
    9 on at
    RE: Portal - How to test my custom error

    Any suggestion for this?

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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Daivat Vartak (v-9davar) Profile Picture

Daivat Vartak (v-9d... 225 Super User 2025 Season 1

#2
Vahid Ghafarpour Profile Picture

Vahid Ghafarpour 136 Super User 2025 Season 1

#3
Eugen Podkorytov Profile Picture

Eugen Podkorytov 106

Overall leaderboard

Product updates

Dynamics 365 release plans