Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines
Your question is very interesting. Normally the SQL will be executes when the report is run. So we use try catch in around the run()
method:
$report = new MyReport;
try {
$report->run();
} catch(\Exception $e) {
}
$report->render();
However, if you are using SQL query directly into widget at view, it seems a little more to perform try catch:
$store = $this->src("db")->query("SELECT ... ")->pipe(new \koolreport\core\DataStore);
try {
$store->requestDataSending();
} catch (\Exception $e)
{
}
ColumnChart::create(array(
"dataSource"=>$store,
...
));
Actually you can create a method to handle all try catch like this in the main class
class MyReport extends \koolreport\KoolReport
{
protected function performSQL($sql) {
$store = $this->src("db")->query(sql)->pipe(new \koolreport\core\DataStore);
try {
$store->requestDataSending();
} catch (\Exception $e)
{
}
return $store;
}
}
and then in any widget, you can do:
ColumnChart::create(array(
"dataSource"=>$this->performSQL("SELECT .... ");
));
Hope my answer helps.
Your question give us an ideas for centralized error handler, I will mark your post as suggestion and forward this topic to our dev.team.
Thank you very much.
Let KoolReport help you to make great reports. It's free & open-source released under MIT license.
Download KoolReport View demo