You are here: Re: How to trigger an error inside a function and make it come from where it was called? « PHP Programming Language « IT news, forums, messages
Re: How to trigger an error inside a function and make it come from where it was called?

Posted by Bruno Rafael Moreira de Barros on 01/14/08 11:29

On Jan 14, 11:17 am, flowover <flowover...@gmail.com> wrote:
> http://ca.php.net/manual/en/language.exceptions.php
>
> On Jan 14, 3:08 am, Bruno Rafael Moreira de Barros
>
> <brunormbar...@gmail.com> wrote:
> > function test1() {
> > trigger_error('My error');
>
> > }
>
> > application.php
>
> > //code...
> > test1();
> > //code...
>
> > I want the trigger_error to say the error came from application.php
> > and the line where it came from. I have a custom error handler, so if
> > some change on the error handler (or test1(), for that matter) is
> > needed, I will gladly do it.
>
> > PHP does it, when you call any PHP function and it errors, it says it
> > came from the file that called it. In my own functions, it says it
> > came from the declaration... which is kind of useless because that is
> > what I already know... but when in the application it happened...
> > that's what's hard to find out.

So I would do:

try {

//code...
test1();
//code...

} catch...

Is that right?

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация