KoolReport's Forum

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

Error handling on report failure #2720

Closed saiful opened this topic on on Jun 10, 2022 - 1 comments

saiful commented on Jun 10, 2022

hi, im using API Datasource to supply data for my report, i have a problem with it; if the API error, the report view is just display blank page. I need to add some exception if my report going error, i have to add some error messages from API and display it over the report page. but how can i throw the error message from API datasource to report page?

Sebastian Morales commented on Jun 10, 2022

If it's a logic error (e.g data empty, different structure, etc) PHP wouldn't throw an exception. You would need to check for data consistency in the API data source and throw an exception yourself:

    protected function requestApiAndSend()
    {
        $rawData = $this->callAPI();
        $data = $this->rawToArray($rawData);
        // check $rawData or $data here and throw exception if needed

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
None yet

None