SitePoint Sponsor

User Tag List

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

    Help! Uncaught exception... Why???

    My try-catch blocks aren't working, and I'm trying to figure out why. I've reduced my code to the bare bones:
    ***************************************

    <?php

    ini_set ('display_errors', 1);
    error_reporting (E_ALL & ~E_NOTICE);

    try
    {
    if (1 == 1)
    throw new Exception("Ick!");
    }
    catch(Exception $e)
    {
    echo $e->getMessage();
    exit();
    }

    ?>
    **************************************

    This code generates the following error message:

    Fatal error: Uncaught exception 'Exception' with message 'Ick!' in /home/goddess/public_html/except.php:9 Stack trace: #0 {main} thrown in /home/goddess/public_html/except.php on line 9


    What in the world? Am I using the concept of try/catch inappropriately, or is it a problem with my server? (Is getmessage() built into the PHP language, or do I need to include something to use it?) If it's a problem with my server, any ideas what it might be (so I can talk with the tech people?) As it is, the tech people have said they don't have any idea...

    Thanks so much!

  2. #2
    SitePoint Addict miggl's Avatar
    Join Date
    Feb 2007
    Location
    Los Angeles, CA
    Posts
    286
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Please stay in the context of you original post (to reduce duplicate postings). Thanks.

    => I have responded there.
    Celebrate Liberty, Freedom, and Rights at The Constitutionalist.

  3. #3
    SitePoint Member
    Join Date
    Mar 2007
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Apologies...

    I changed the code that I was asking about (to fix the out-of-scope issue that someone suggested), but it's still generating the same problem.

    I posted a new thread because the code I'm asking about in this post is substantially different than the code I was asking about in the last post, but I apologize if I shouldn't have.


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
  •