NYCPHP Meetup

NYPHP.org

[nycphp-talk] Re: [PHP-DB] PHP 5 Error Handling

Joseph Crawford codebowl at gmail.com
Wed Sep 15 15:59:34 EDT 2004


guys thanks for the responses, i am sure i may be able to parse the
results of $e->getTrace() to get the results i want ;)


On Wed, 15 Sep 2004 09:25:05 -0500, Gary Every
<gary.every at ingramentertainment.com> wrote:
> Good question. I've tried the __LINE__ and __FILE__ in my
> error-handling, but it does the same thing you're experiencing, getting
> the line in the function/method as opposed to the actual error line. The
> only way I've gone around it is whenever there may be an exception, such
> as a sql statement, etc I assign $line_no = __LINE__ and if an exception
> gets thrown, the $line_no is captured, and I can use the info to print
> to the logs or the screen or ...
> 
> G.
> 
> Gary Every
> Sr. UNIX Administrator
> Ingram Entertainment Inc.
> 2 Ingram Blvd, La Vergne, TN 37089
> "Pay It Forward!"
> 
> 
> 
> 
> -----Original Message-----
> From: Joseph Crawford [mailto:codebowl at gmail.com]
> Sent: Tuesday, September 14, 2004 5:55 AM
> To: [PHP-DB] Mailing List
> Subject: [PHP-DB] PHP 5 Error Handling
> 
> Guys,
> 
> i have been working with custom exception classes that extend the
> general exception.  Here is some code i have
> 
>        public function command($cmd) {
>                if($cmd) {
>                        $res = fputs($this->connection, $cmd);
>                        $this->response = fgets($this->connection, 128);
>                        switch($this->getCode()) {
>                                case 500:
>                                        throw new CommandException($cmd);
>                                break;
>                        }
>                }
>        }
> 
>        public function selectGroup($group) {
>                $this->group = $group;
>                if(substr($this->response,0,3) == "200") {
> 
>                        THIS IS THE LINE THAT THROWS THE ERROR
>                        $this->command("NoSuchCommand\n");
> 
>                        $this->response = fgets($this->connection, 1024);
>                }
>                $info = split(" ", $this->response);
> 
>                $this->first = $info[2];
>                $this->last = $info[3];
>        }
> 
> now when the error is thrown and i do $e->getLine(); it shows the line
> of the file where the throw statement is.  Is there a way to make it
> show the actual line number of the line that is the error? the
> $this->command("NoSuchCommand\n"); line.
> 
> --
> Joseph Crawford Jr.
> Codebowl Solutions
> codebowl at gmail.com
> 802-558-5247
> 
> For a GMail account
> contact me OFF-LIST
> 
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 



-- 
Joseph Crawford Jr.
Codebowl Solutions
codebowl at gmail.com
802-558-5247

For a GMail account
contact me OFF-LIST



More information about the talk mailing list