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 wrote: > Hi Saša, >

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. Ro

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 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 change it later on

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 Саша Стаменковић
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 wrote: > > There's answer for it in the code sample I gave you. > Error handler will inter

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

2009-09-28 Thread Karol Grecki
There's answer for it in the code sample I gave you. Error handler will intercept all errors even if they were silenced with @ operator. You need to check if error reporting is disabled at the time the error happens. Karol umpirsky wrote: > > Now I get a lot of crap catched :) > For example: >

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) [function.fopen]: failed to open stream: No such file or directory in /mnt/home/sasas/www/Zend/Loader.php #165. which is ok, but this: fopen(/mnt/home/sasas/www/auto/appli

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 wrote: > > If you named your functions differently you need to

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() expect

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

2009-09-28 Thread Саша Стаменковић
No, I have phpError static method in ErrorController, set_error_handler(array('ErrorController', 'phpError')); calls it staticly, not through MVC, right? Regards, Saša Stamenković On Mon, Sep 28, 2009 at 12:57 PM, till wrote: > On Mon, Sep 28, 2009 at 12:54 PM, Саша Стаменковић > wrote: > > W

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

2009-09-28 Thread till
On Mon, Sep 28, 2009 at 12:54 PM, Саша Стаменковић 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 Саша Стаменковић
*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 wrote: > > Try this, it works for me. > > class

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 $errfile:$

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

2009-09-24 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 wrote: > > 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_AL

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); > } > set_error_handler('exce

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 wrote: > Hi, > > What i did was writing a function that simply throws an exc

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); } set_error_handler('exceptionThro

[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 contr

[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 controll