Error reporting quandry...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • The Plankmeister

    Error reporting quandry...


    I'm doing this:

    error_reporting (E_ERROR | E_WARNING);
    set_error_handl er("my_error_ha ndler");

    But it still traps E_NOTICE errors... Most peculiar. What's going on?

    Plankmeister.


  • Andy Hassall

    #2
    Re: Error reporting quandry...

    On Thu, 8 Jan 2004 13:56:36 +0100, "The Plankmeister"
    <plankmeister_N OSPAM_@hotmail. com> wrote:
    [color=blue]
    >I'm doing this:
    >
    >error_reportin g(E_ERROR | E_WARNING);
    >set_error_hand ler("my_error_h andler");
    >
    >But it still traps E_NOTICE errors... Most peculiar. What's going on?[/color]

    Read the docs. http://uk2.php.net/set_error_handler

    Comment

    • Pedro Graca

      #3
      Re: Error reporting quandry...

      The Plankmeister wrote:[color=blue]
      > error_reporting (E_ERROR | E_WARNING);
      > set_error_handl er("my_error_ha ndler");[/color]
      [color=blue]
      > But it still traps E_NOTICE errors... Most peculiar. What's going on?[/color]

      When you define a error_handler, your function will trap _all_ errors no
      matter what error_reporting has.

      You may, however, filter the errors you want to deal with:

      #v+

      <?php
      function my_error_handle r($err_no, $err_str, $file, $line) {
      if ($err_no == E_NOTICE) {
      // do nothing and
      return;
      }
      // ... deal with other errors
      exit("$err_no, $err_str in $file:$line\n") ;
      }

      error_reporting (0);
      set_error_handl er('my_error_ha ndler');

      $x = $a; // NOTICE!
      echo "NOTICE passed\n\n";

      $x = 3/0; // FATAL ERROR
      echo "FATAL ERROR passed\n\n";
      ?>

      #v-
      --
      --= my mail box only accepts =--
      --= Content-Type: text/plain =--
      --= Size below 10001 bytes =--

      Comment

      Working...