Error Handling and Show Error Message from API in Canvas App

Patch(
Tests,
Defaults(Tests),
{Text: "Power Apps Test"}
)
Set(
varSearchResults,
CustomConnector.Search(
{SearchText: "Power Apps"}
)
)
IfError function is part of an experimental feature and are subject to change. That function is available only when the Formula-level error management experimental feature in Settings > Upcoming features > Experimental is turned on. (Yes, you read it right. It is still an *experimental* feature after more than 4 years and counting.)
IfError(
,
Patch(
Tests,
Defaults(Tests),
{Text: "Power Apps Test"}
)
Notify(
"There is an error while creating a row in Test table.",
NotificationType.Error,
5000
),
false
);
IfError(
,
Patch(
Tests,
Defaults(Tests),
{Text: "Power Apps Test"}
)
Notify(
FirstError.Details.HttpResponse,
NotificationType.Error,
5000
),
false
);
IfError(
,
Patch(
Tests,
Defaults(Tests),
{Text: "Power Apps Test"}
)
Notify(
Match(
FirstError.Details.HttpResponse,
"\""code"":""(?<code>[^""]*)"",""message"":""(?<message>[^""]*)"
).message,
NotificationType.Error,
5000
),
false
);
Set(varSearchResults, Blank());
Set(varMessage, "Loading...");
Set(
varSearchResults,
IfError(
CustomConnector.Search(
{SearchText: "Power Apps"}
),
Set(
varMessage,
Match(
FirstError.Details.HttpResponse,
"\""code"":""(?<code>[^""]*)"",""message"":""(?<message>[^""]*)"
).message
),
If (
(CountRows(varSearchResults) > 0),
Set(varMessage, ""),
Set(varMessage, "No data available"});
);
);
);
Summary
Published on:
Learn moreRelated posts
🔓 Understanding the “Access app scope” Feature in Canvas App Components (Power Apps)
💡 Introduction In Power Apps Canvas Apps, components play a crucial role in building reusable UI and logic blocks. However, traditionally, co...
Canvas App | Easy way to use SVG icons with PowerIcons
In my previous articles, I explained how to use SVG icons in Canvas Apps by manually modifying the SVG content to make it compatible with Canv...
How to Detect that a PCF is Running Inside a Canvas App / Custom Page
Usually my target is to develop a PCF working inside all types of apps: Canvas App (or Custom Pages), Model-Driven Apps and hopefully also ins...
Power Up Your Canvas Apps with No Code Interactive Maps: A Game-Changer for Sales and Field Teams!
If you’re a Sales Manager juggling territories, appointments, and customer data across multiple tools, it’s time to simplify things—with maps ...
Debug PCFs using a Browser Autoresponder Extension (MDA & Canvas Apps)
I’m sure the Autoresponder idea for Debugging PCFs (or WebResources) is not new to you. Debugging with an autoresponder solution is a li...