CodeIgniter Forums
Prevent gzuncompress to throw ErrorException on invalid data - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Prevent gzuncompress to throw ErrorException on invalid data (/showthread.php?tid=88439)



Prevent gzuncompress to throw ErrorException on invalid data - StefanKittel - 09-08-2023

Hello,
I'm working on an controller in the newest CI-Version to load and uncompress date.
Currently I'm testing on invalid data.
If the data is invalid by a modified data, I put "hello world" in it, CI throws an ErrorException.
ErrorException
gzuncompress(): data error

But I would like to handle the error myself using the return value.
How can I prenvet this?
Try and catch does not work.

PHP Code:
try
{
    $this->Config['OutputContent'] = gzuncompress($OutputContentGZ);
}
catch (
Exception $ex)
{
    return 2022;



Thanks
Stefan


RE: Prevent gzuncompress to throw ErrorException on invalid data - StefanKittel - 09-08-2023

Found it myself with the docu :-)
using
Code:
\Exception
makes the difference
Code:
try
{
    $this->Config['OutputContent'] = gzuncompress($OutputContentGZ);
}
catch (\Exception $ex)
{
    return 2022;


Stefan