开发者

check for error

开发者 https://www.devze.com 2022-12-10 16:32 出处:网络
I have my own AppCotroller and using the beforeRender method to make changes to $th开发者_StackOverflow社区is->viewPath based on the desired output format.

I have my own AppCotroller and using the beforeRender method to make changes to $th开发者_StackOverflow社区is->viewPath based on the desired output format.

Is there a way I can check if Cake is currently outputting an error message? If I change the viewPath and then it's displaying an error (like can't load model, etc) it will error on the error :)


By the time Cake is displaying the error it should already be too late to do something about it. Not quite sure why you'd get an error about missing models when you change the viewPath, I hope that was just an example.

You might have some luck overriding or extending the ErrorHandler to intercept errors, but I wouldn't recommend doing that. Errors don't exist to be hidden, they're there to tell you something.

Creating a custom View might be a good idea depending on what you want to do (see the MediaView as an example of an alternative view).

The best thing to do though should be to avoid triggering errors by only allowing certain, predefined views to be set or making sure that a certain view file exists before trying to invoke it.

0

精彩评论

暂无评论...
验证码 换一张
取 消