rubing Posted May 31, 2008 Share Posted May 31, 2008 I thought someone could explain why the following code doesn't work. First, I make a call to a class method. I want to catch any exceptions that are thrown by this method. I thought the exceptions thrown in the class would bubble up to script level?? I tried putting a try block around the call to my class method, but this just resulted in the underlying class exception not being caught. $grab->request_post_info($karma); catch (Exception $e) { $query="INSERT INTO mp3 (sutrasite) VALUES ('$sutra')"; $conn->query($query); exit; } Link to comment https://forums.phpfreaks.com/topic/108130-unexpected-catch-block/ Share on other sites More sharing options...
Prismatic Posted May 31, 2008 Share Posted May 31, 2008 <?php try { $grab->request_post_info($karma); } catch (Exception $e) { $query="INSERT INTO mp3 (sutrasite) VALUES ('$sutra')"; $conn->query($query); } ?> That doesn't work? edit - Actually you'll want to catch any exceptions in the $grab object class, not here. Link to comment https://forums.phpfreaks.com/topic/108130-unexpected-catch-block/#findComment-554230 Share on other sites More sharing options...
rubing Posted May 31, 2008 Author Share Posted May 31, 2008 Nope. When I do that I get the following error Fatal error: Uncaught exception 'Exception' with message 'my error message' in /path/to/myclass.inc:96 Stack trace: #0 /path/to/my/script.php(45): class_name->get_mp3(NULL) #1 {main} thrown in /path/to/myclass.inc on line 96 Link to comment https://forums.phpfreaks.com/topic/108130-unexpected-catch-block/#findComment-554237 Share on other sites More sharing options...
rubing Posted May 31, 2008 Author Share Posted May 31, 2008 I had to create a sloppy work-around b/c of this. If anyone has any idea please let me know! Link to comment https://forums.phpfreaks.com/topic/108130-unexpected-catch-block/#findComment-554443 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.