KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

DataSource error handling #2967

Open GHSix opened this topic on on Jan 30, 2023 - 2 comments

GHSix commented on Jan 30, 2023

Sometimes a query may not return rows, in my case, when the query subject user is still not found, so the query will return empty. For the AutoMaker class, this seems transparent, it just pass back this empty result. But for the Graphics or Proccess it may cause errors as in this print:

Since the result set is empty, there is no "dt" (my date) collumn to be plot and an error is raised in the middle of the KR Dashboard.

My question is:

  1. Is there any way to disable this errors in production?

  2. If not, there is a way to extend AutoMaker class or any other so I can intercept the result set before it get back to the rest of KR and do something about it to not be empty? For example, use the SELECT part of query string to create a fake result set with blank values to avoid this errors for the end user.

  3. Any other fun tricks to error handling?

ps. I'm using { return \AutoMaker::rawSQL("SELECT ...")->params([...]); } all the way down.

KoolReport commented on Jan 31, 2023

For your question:

Q1. Yes, please set $this->debugMode(false) in App object and you will not see error.

Q2. Yes, if return data is not very large, you can run the query immediately and base on the data to decide.

$dataStore = \AutoMaker::rawSQL("SELECT ...")->params([...])->run();
If($dataStore->count()>0) {
return $dataStore;
} else {
    return ["dt"=>"","fakeKey"=>"fakeValue"];
}

Q3. Widget, Dashboard or Application does have event onError($exception) that you can use to log error while debugMode is turned off.

GHSix commented on Jan 31, 2023

Q1. Now I remember that I saw this one before. I miss a search feature in the docs a lot.

But with this off, the panel will nevel load and will keep the load animation forever, wich still looks like an error. I need something mode user friendly, like the metric widgets that just display a message saying there is no data to show.

--

Q2. I was in the holpe you could tell me how to add this handling in the AutoMaker.php that extends MySQL class, so it could work dashboard-wide, if possible.

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed

Dashboard