JpGraph Error Handler!

185 views
Skip to first unread message

Claude Deslandes

unread,
Feb 13, 2019, 1:48:56 PM2/13/19
to JpGraph
Hello All JpGraph FANS!

    I have a page that calls a few generated graphics directly from a include("jpgraph_tb_inte.php"); instead of a <img src='jpgraph_tb_inte.php'> since the graphic are clickable with link generated from a $graph->StrokeCSIM. Everything works fine until I get an error on a MySqli request where i get a Jpgraph generated message that says nothing to help me find my error :

Fatal error: Uncaught TypeError: Argument 1 passed to JpGraphException::defaultHandler() must be an instance of Exception, instance of Error given in C:\MesProjets\Profileur2\siteweb\jpgraph\src\jpgraph_errhandler.inc.php:158 Stack trace: #0 [internal function]: JpGraphException::defaultHandler(Object(Error)) #1 {main} thrown in C:\MesProjets\Profileur2\siteweb\jpgraph\src\jpgraph_errhandler.inc.php on line 158

   I think that when calling directly the jpgraph_tb_inte.php with an include, some local variables are set to thrown some error in a JpGraph format or some sort.  Before I throw my computer by the windows, can somebody give me a solution on what do to and how to shut down this "defaultHandler" or errors!

   Claude :-)

David Martin

unread,
Feb 14, 2019, 5:43:31 AM2/14/19
to JpGraph
Can't help you with changing how JPGraph handles errors but I would suggest that you using proper error handling in your code so that bad or missing data never reaches JPGraph in the first place. Besides, you don't want errors, especially like the one you posted, to be seen as they (may) provide too much information to someone who might want to break into your site.

As far as I know there aren't any "hooks" available in JPGraph to change how it handles errors.

Claude Deslandes

unread,
Feb 17, 2019, 12:58:52 PM2/17/19
to JpGraph
Good day David,

     I understand... this is a message I get on my development server...   while programming, if I mise a ; , then I do get that jpgraph error instead of pointing me to the file in causing the error.   Do when working with CSIM JPgraph, a simple missing ; can take me a few minutes to find out where it is missing.   There has to be a way to stop JpGraph reacting this way.

     Claude :-)

David Martin

unread,
Feb 18, 2019, 5:18:00 AM2/18/19
to JpGraph
Do you have an exception handler in your code? If not then that would be the logical place to try and catch an exception though it isn't clear whether or not that would override the error handler in JPGraph. I'm not aware of anything JPGraph that provides a way to alter how it handles errors.

Gavin D

unread,
Nov 26, 2019, 8:00:52 PM11/26/19
to JpGraph
Hi Claude,

Been running into this issue myself, it looks like the JpGraph is got the wrong argument type, as of PHP 7.0 they are now also throwing Error exceptions.


Note that providing an explicit Exception type hint for the ex parameter in your callback will cause issues with the changed exception hierarchy in PHP 7.

As of Version: v4.2.10

I've had to change src\jpgraph_errhandler.inc.php on line 158 from:

    static public function defaultHandler(Exception $exception) {

to

    static public function defaultHandler($exception) {

Ideally it would be nice to use Throwable, but for the library to still be compatible with PHP 5.*, it can't be used.
Reply all
Reply to author
Forward
0 new messages