We have implemented custom error handling in Power Bi component in our angular app from here Docs .Something like this:
this.report.on('error', (event: any) => {
const error = event.detail;
console.log("event",event)
//If error is not Fatal log the error and continue
if (error.level !== pbi.models.TraceType.Fatal) {
console.error(error);
if (this.retryCount < this.maxRetryCount) {
this.retryCount++;
this.isReady = false;
setTimeout(() => {
this.loadReport(ReportDashboardConfig);
}, this.retryCount * 500);
} else {
this.isError = true;
}
}
But when we encounter error we don't receive any level property in our detail property in event object. This is the event.detail object:
{
"message": "QueryUserError",
"detailedMessage": "Can't display the visual.. Could not render a report visual titled: undefined",
"technicalDetails": {
"requestId": "Some value here"
}
How to get the level of the error.
If you check the IError interface, level is an optional property, it means that some error may not contain error level. to handle such scenarios use else condition, or if you want to handle any specific error use the "message" or "detailedMessage".
Example:
if (error.level) {
if (error.level >= models.TraceType.Fatal) {
// DO SOMETHING
}
else if (error.level < models.TraceType.Fatal) {
// DO SOMETHING
}
}
else {
if (error.detailedMessage === "Can't display the visual.. Could not render a report visual titled: undefined") {
// DO SOMETHING
}
}
Reference: