SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Oct 2008
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    exception not caught

    hi

    I have the following trivial snipplet:

    try{
    throw new Exception("uncaught");
    }catch (Exception $e){
    echo $e;
    }

    My Server gives me following fatal Error:
    [error] PHP Fatal error: Uncaught exception 'Exception' with message 'uncaught' in XXXX/etest.php:9\nStack trace:\n#0 {main}\n thrown in XXXX/etest.php on line 9

    There is nothing more in the script, nothing included. Locally this script does as it should, so it has to be some configuration issue. But I have no clue any more where to find it.

    Am I blind?
    Thanks for any suggestion

    Kaspar

  2. #2
    SitePoint Addict
    Join Date
    Oct 2008
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sure you did not mean to do this?
    PHP Code:
    echo $e->getMessage(); 

  3. #3
    SitePoint Evangelist
    Join Date
    Jun 2006
    Location
    Wigan, Lancashire. UK
    Posts
    523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
     try{
           throw new 
    Exception("uncaught");
     }catch (
    Exception $e){
         echo 
    $e;
     } 
    You're catching the error correctly, then trying to echo the error object, which doesn't have a toString method.

    type
    PHP Code:
    echo $e->getMessage(); 
    ---
    Development Projects:
    PHPExcel
    PHPPowerPoint

  4. #4
    SitePoint Member
    Join Date
    Oct 2008
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    as the standard Exception class has a __toString() function echo $e should be ok. In fact it is locally.

    But anyhow using $e->getMessage() doesn't change anything

    Thanks for your rapid answers!

  5. #5
    SitePoint Member
    Join Date
    Oct 2008
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I finally found it. It was a bug in eAccelerator. I am not allowed to post the link here, I try to do it anyhow: eaccelerator.net/ticket/242


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •