Re: [fw-general] Turn PHP errors/warnings/notices into exceptions

2009-09-29 Thread drm
Hi Saša, Basically, if the exception isn't thrown within the dispatch loop, you would have to catch the exception in your index.php and dispatch to your error controller yourself. To make sure your errors and notices etc are thrown as exceptions you would need an error handler like mine.

Re: [fw-general] Turn PHP errors/warnings/notices into exceptions

2009-09-29 Thread Саша Стаменковић
Thanks. I'm satisfied with just logging all warnings...so I can fix them during development and always track them in my custom log on production since I don't have access to php error log on my shared hosting :) Regards, Saša Stamenković On Tue, Sep 29, 2009 at 9:56 AM, drm d...@melp.nl wrote:

Re: [fw-general] Turn PHP errors/warnings/notices into exceptions

2009-09-28 Thread Karol Grecki
Try this, it works for me. class X_Error_Handler { public static function handle($errno, $errstr, $errfile, $errline) { //this allows error suppression in 3rd party code to work if (!error_reporting()) return; throw new X_RuntimeException($errstr . in

Re: [fw-general] Turn PHP errors/warnings/notices into exceptions

2009-09-28 Thread Саша Стаменковић
*Warning*: set_error_handler() expects the argument (ErrorController::phpError) to be a valid callback in * /mnt/home/sasas/www/auto/application/Bootstrap.php* on line *16* Regards, Saša Stamenković On Mon, Sep 28, 2009 at 12:29 PM, Karol Grecki kgre...@gmail.com wrote: Try this, it works

Re: [fw-general] Turn PHP errors/warnings/notices into exceptions

2009-09-28 Thread till
On Mon, Sep 28, 2009 at 12:54 PM, Саша Стаменковић umpir...@gmail.com wrote: Warning: set_error_handler() expects the argument (ErrorController::phpError) to be a valid callback in /mnt/home/sasas/www/auto/application/Bootstrap.php on line 16 You probably need phpErrorAction() ? Till

Re: [fw-general] Turn PHP errors/warnings/notices into exceptions

2009-09-28 Thread Karol Grecki
If you named your functions differently you need to modify the code accordingly. Also, make sure that this class is actually loaded or can be loaded with autoloader before you try to use it and register the error handler. Regards Karol umpirsky wrote: *Warning*: set_error_handler() expects

Re: [fw-general] Turn PHP errors/warnings/notices into exceptions

2009-09-28 Thread Саша Стаменковић
Nice answer Grecki, thanks. require_once 'controllers/ErrorController.php'; set_error_handler(array('ErrorController', 'phpError')); fixed problem. Strange :) Regards, Saša Stamenković On Mon, Sep 28, 2009 at 1:03 PM, Karol Grecki kgre...@gmail.com wrote: If you named your functions

Re: [fw-general] Turn PHP errors/warnings/notices into exceptions

2009-09-28 Thread Саша Стаменковић
Now I get a lot of crap catched :) For example: fopen(/mnt/home/sasas/www/auto/application/controllers/ImagesController.php) [a href='function.fopen'function.fopen/a]: failed to open stream: No such file or directory in /mnt/home/sasas/www/Zend/Loader.php #165. which is ok, but this:

Re: [fw-general] Turn PHP errors/warnings/notices into exceptions

2009-09-28 Thread Саша Стаменковић
But I want to catch errors that are not suppressed with @. If I check if error reporting is on, I will catch all of them or no one. Regards, Saša Stamenković On Mon, Sep 28, 2009 at 1:36 PM, Karol Grecki kgre...@gmail.com wrote: There's answer for it in the code sample I gave you. Error

Re: [fw-general] Turn PHP errors/warnings/notices into exceptions

2009-09-28 Thread Karol Grecki
You need to check that in order to ignore suppressed errors. I gave you working code that does exactly what you want. I suggest you use it. You can always change it later once you understand how it works. Karol umpirsky wrote: But I want to catch errors that are not suppressed with @. If I

Re: [fw-general] Turn PHP errors/warnings/notices into exceptions

2009-09-28 Thread Саша Стаменковић
Man, this really works. Thanks :) Regards, Saša Stamenković On Mon, Sep 28, 2009 at 2:03 PM, Karol Grecki kgre...@gmail.com wrote: You need to check that in order to ignore suppressed errors. I gave you working code that does exactly what you want. I suggest you use it. You can always

Re: [fw-general] Turn PHP errors/warnings/notices into exceptions

2009-09-25 Thread Саша Стаменковић
Thx. But I can't see how this can help :P Regards, Saša Stamenković On Thu, Sep 24, 2009 at 3:00 PM, Vincent de Lau vinc...@delau.nl wrote: What i did was writing a function that simply throws an exception and passing that function to set_error_handler, something like this:

[fw-general] Turn PHP errors/warnings/notices into exceptions

2009-09-24 Thread Саша Стаменковић
I'm trying to do this with set_error_handler(), my will is to trigger Error controller and catch this as application error, since I want to log all errors in one place - Error controller. I tried with setting error handler in bootstrap to function in index.php and that function calls error

[fw-general] Turn PHP errors/warnings/notices into exceptions

2009-09-24 Thread umpirsky
I'm trying to do this with set_error_handler(), my will is to trigger Error controller and catch this as application error, since I want to log all errors in one place - Error controller. I tried with setting error handler in bootstrap to function in index.php and that function calls error

Re: [fw-general] Turn PHP errors/warnings/notices into exceptions

2009-09-24 Thread drm
Hi, What i did was writing a function that simply throws an exception and passing that function to set_error_handler, something like this: error_reporting(E_ALL); function exceptionThrower($type, $errMsg, $errFile, $errLine) { throw new Exception($errMsg); }

Re: [fw-general] Turn PHP errors/warnings/notices into exceptions

2009-09-24 Thread Саша Стаменковић
Thx, thats ok, but is there any way to trap error in ErrorController, maybe redirect to /error, but then you need to pass error msg through url...messy :) Regards, Saša Stamenković On Thu, Sep 24, 2009 at 2:33 PM, drm d...@melp.nl wrote: Hi, What i did was writing a function that simply

RE: [fw-general] Turn PHP errors/warnings/notices into exceptions

2009-09-24 Thread Vincent de Lau
What i did was writing a function that simply throws an exception and passing that function to set_error_handler, something like this: error_reporting(E_ALL); function exceptionThrower($type, $errMsg, $errFile, $errLine) { throw new Exception($errMsg); }